hsiang-c commented on code in PR #3643:
URL: https://github.com/apache/datafusion-comet/pull/3643#discussion_r3075001472


##########
spark/src/main/scala/org/apache/comet/serde/arrays.scala:
##########
@@ -623,6 +624,57 @@ object CometSize extends CometExpressionSerde[Size] {
 
 }
 
+object CometArraysZip extends CometExpressionSerde[ArraysZip] {
+  override def getSupportLevel(expr: ArraysZip): SupportLevel = {
+    expr.dataType match {
+      case _: ArrayType => Compatible()
+      case other =>
+        // this should be unreachable because Spark only supports array inputs
+        Unsupported(Some(s"Unsupported child data type: $other"))
+    }
+  }
+
+  override def convert(
+      expr: ArraysZip,
+      inputs: Seq[Attribute],
+      binding: Boolean): Option[ExprOuterClass.Expr] = {
+
+    val exprChildren: Seq[Option[ExprOuterClass.Expr]] =
+      expr.children.map(exprToProtoInternal(_, inputs, binding))
+    val names: Seq[Any] = expr.names.map(_.eval(EmptyRow))
+
+    // mimic Spark's ArraysZip behavior: returns NULL if any argument is NULL
+    val combinedNullCheck = expr.children.map(child => 
IsNotNull(child)).reduce(And)

Review Comment:
   Example of Spark's `arrays_zip`:
   
   ```shell
   scala> spark.sql("SELECT arrays_zip(array(1, 2, 3), array(1), 
NULL)").show(100, false)
   +------------------------------------------+
   |arrays_zip(array(1, 2, 3), array(1), NULL)|
   +------------------------------------------+
   |NULL                                      |
   +------------------------------------------+
   
   scala> spark.sql("SELECT arrays_zip(NULL, array(1, 2, 3))").show(100, false)
   +--------------------------------+
   |arrays_zip(NULL, array(1, 2, 3))|
   +--------------------------------+
   |NULL                            |
   +--------------------------------+
   ```



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