MaxGekk commented on a change in pull request #28328:
URL: https://github.com/apache/spark/pull/28328#discussion_r415676504



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Column.scala
##########
@@ -828,11 +828,12 @@ class Column(val expr: Expression) extends Logging {
    * @since 2.4.0
    */
   def isInCollection(values: scala.collection.Iterable[_]): Column = withExpr {
-    val hSet = values.toSet[Any]
-    if (hSet.size > SQLConf.get.optimizerInSetConversionThreshold) {
-      InSet(expr, hSet)
+    val exprValues = values.toSeq.map(lit(_).expr)
+    if (exprValues.size > SQLConf.get.optimizerInSetConversionThreshold) {
+      val elemType = exprValues.headOption.map(_.dataType).getOrElse(NullType)
+      InSet(expr, exprValues.map(_.eval()).toSet, elemType)

Review comment:
       To make sure, we need something similar to `In.checkInputDataTypes()` in 
`InSet`:
   
https://github.com/apache/spark/blob/7d8216a6642f40af0d1b623129b1d5f4c86bec68/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala#L313-L322
   
   I could add such check in the PR if you don't mind.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to