sunchao commented on code in PR #7456:
URL: https://github.com/apache/datafusion-comet/pull/7456#discussion_r4746933466


##########
spark/src/main/scala/org/apache/comet/serde/strings.scala:
##########
@@ -393,6 +393,13 @@ object CometConcat
 
   override def getIncompatibleReasons(): Seq[String] = Seq(collationReason)
 
+  // Spark's generated code for Concat evaluates each argument only where 
every earlier one is not
+  // NULL, and the native concat returns NULL wherever an argument is NULL.
+  override def convert(expr: Concat, inputs: Seq[Attribute], binding: 
Boolean): Option[Expr] = {
+    val proto = super.convert(expr, inputs, binding)
+    if (expr.children.length > 1) withNullShortCircuit(expr, proto) else proto

Review Comment:
   `Concat.eval` evaluates all string children, while generated Concat stops at 
the first null. `ArrayFilter` evaluates its lambda through `eval` even with 
default codegen. With ANSI enabled, run `SELECT filter(array(s), x -> 
concat(CAST(n AS STRING), CAST(CAST(x AS INT) AS STRING)) = '17') FROM t` on 
`(n,s) = (NULL,'bad'), (1,'7')`. Spark 3.5.9 raises CAST_INVALID_INPUT. A 
native array_filter probe with the new wrapper returned `[[], ['7']]` because 
the null `n` masked the bad cast. A direct projection also differs in 
NO_CODEGEN. Can we keep eager concat in interpreted contexts (or delegate those 
cases to Spark) and test the lambda plus generated and interpreted projections?



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