This is an automated email from the ASF dual-hosted git repository.

wenchen pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 2828495  [SPARK-31563][SQL][FOLLOWUP] Create literals directly from 
Catalyst's internal value in InSet.sql
2828495 is described below

commit 2828495eea1120ef635d1ae64fde6470363ff7b5
Author: Max Gekk <[email protected]>
AuthorDate: Wed Apr 29 06:44:22 2020 +0000

    [SPARK-31563][SQL][FOLLOWUP] Create literals directly from Catalyst's 
internal value in InSet.sql
    
    ### What changes were proposed in this pull request?
    In the PR, I propose to simplify the code of `InSet.sql` and create 
`Literal` instances directly from Catalyst's internal values by using the 
default `Literal` constructor.
    
    ### Why are the changes needed?
    This simplifies code and avoids unnecessary conversions to external types.
    
    ### Does this PR introduce any user-facing change?
    No
    
    ### How was this patch tested?
    By existing test `SPARK-31563: sql of InSet for UTF8String collection` in 
`ColumnExpressionSuite`.
    
    Closes #28399 from MaxGekk/fix-InSet-sql-followup.
    
    Authored-by: Max Gekk <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
    (cherry picked from commit 86761861c28e1c854b4f78f1c078591b11b7daf3)
    Signed-off-by: Wenchen Fan <[email protected]>
---
 .../scala/org/apache/spark/sql/catalyst/expressions/predicates.scala    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
index a016ed6..6513bb2 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
@@ -395,7 +395,7 @@ case class InSet(child: Expression, hset: Set[Any]) extends 
UnaryExpression with
   override def sql: String = {
     val valueSQL = child.sql
     val listSQL = hset.toSeq
-      .map(elem => Literal(convertToScala(elem, child.dataType)).sql)
+      .map(elem => Literal(elem, child.dataType).sql)
       .mkString(", ")
     s"($valueSQL IN ($listSQL))"
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to