rich7420 commented on code in PR #6073:
URL: https://github.com/apache/datafusion-comet/pull/6073#discussion_r4060673176


##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -49,6 +49,26 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
     checkCometAnswer(cometDf, sparkAnswer)
   }
 
+  test("nested floating point membership uses native In and InSet") {
+    withTable("nested_in_plan") {
+      sql("CREATE TABLE nested_in_plan (a ARRAY<DOUBLE>) USING parquet")
+      sql("INSERT INTO nested_in_plan VALUES (array(CAST('-0.0' AS DOUBLE)))")

Review Comment:
   `a IN (array(double('0.0')))` still returns `false` for `a = [-0.0]` (Spark: 
`true`). `OptimizeIn` rewrites singleton or duplicate candidates to equality 
comparisons. Please normalize `Eq`/`Neq` operands too and cover that path with 
the regression below.
   
   This suggestion adds the regression only. It fails on this head. With Eq/Neq 
normalization added, all five focused tests pass on Spark 4.1.3.
   
   ```suggestion
         sql("""INSERT INTO nested_in_plan VALUES
           |(array(CAST('-0.0' AS DOUBLE))), (array(CAST('0.0' AS DOUBLE))),
           |(array(CAST('NaN' AS DOUBLE))), (array(CAST('1.0' AS DOUBLE))),
           |(array(CAST(NULL AS DOUBLE))), (array()), (NULL)""".stripMargin)
         withSQLConf(SQLConf.OPTIMIZER_EXCLUDED_RULES.key -> "") {
           for (size <- Seq(1, 2)) {
             val candidates = Seq.fill(size)("array(CAST('0.0' AS 
DOUBLE))").mkString(", ")
             val df = sql(s"SELECT a IN ($candidates), a NOT IN ($candidates) 
FROM nested_in_plan")
             val expressions = 
df.queryExecution.optimizedPlan.flatMap(_.expressions)
             assert(!expressions.exists(_.exists(_.isInstanceOf[In])))
             checkSparkAnswerAndImpl(df, native = Seq("equalto"))
           }
         }
   ```
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to