cloud-fan commented on code in PR #42450:
URL: https://github.com/apache/spark/pull/42450#discussion_r1299530738


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenFallback.scala:
##########
@@ -46,21 +46,54 @@ trait CodegenFallback extends Expression {
     val objectTerm = ctx.freshName("obj")
     val placeHolder = ctx.registerComment(this.toString)
     val javaType = CodeGenerator.javaType(this.dataType)
-    if (nullable) {
-      ev.copy(code = code"""
-        $placeHolder
-        Object $objectTerm = ((Expression) references[$idx]).eval($input);
-        boolean ${ev.isNull} = $objectTerm == null;
-        $javaType ${ev.value} = ${CodeGenerator.defaultValue(this.dataType)};
-        if (!${ev.isNull}) {
-          ${ev.value} = (${CodeGenerator.boxedType(this.dataType)}) 
$objectTerm;
-        }""")
+    val childrenGen = children.map(_.genCode(ctx))
+    val childrenCode = childrenGen.map(_.code).mkString("\n")
+    val childrenParameter = childrenGen.map(_.value).mkString(", ")
+    val clazz = this.getClass.getName
+    if (supportWholeStageCodegen) {
+      if (nullable) {
+        ev.copy(code =
+          code"""
+          $placeHolder
+          ${childrenCode}
+          Object $objectTerm = null;
+          if(${childrenGen.map(_.isNull).mkString(" || ")}) {
+            $objectTerm = null;
+          } else {
+            $objectTerm = (($clazz) 
references[$idx]).nullSafeEval(${childrenParameter});

Review Comment:
   This seems wrong. The input of `nullSafeEval` is the input row, not the 
children expression evaluation results. Have you updated all the 
`CodegenFallback` implementations?



-- 
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: reviews-unsubscr...@spark.apache.org

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