unikdahal commented on code in PR #5414:
URL: https://github.com/apache/datafusion-comet/pull/5414#discussion_r3836280849


##########
spark/src/main/scala/org/apache/comet/serde/structs.scala:
##########
@@ -250,7 +250,9 @@ object CometJsonToStructs extends 
CometCodegenDispatch[JsonToStructs] with Nativ
 
   private def isSupportedSchema(dt: DataType): Boolean = dt match {
     case StructType(fields) =>
-      fields.nonEmpty && fields.forall(f => isSupportedSchema(f.dataType))
+      // A struct's `fields` can be empty -- e.g. `from_json(col, 
'struct<>')`'s target schema.
+      // With no fields to check, this holds vacuously.
+      fields.forall(f => isSupportedSchema(f.dataType))

Review Comment:
   Thanks for the quick, thorough review @sunchao .
   
   Good catch, the recursive Scala predicate let `struct<outer:struct<>>` 
through while
   `finish_builder`'s nested struct branch still panicked on it. Fixed with the 
same
   `is_empty()` check, using `null_buf.len()` for the row count. Added a 
regression test
   covering the nested case. All 10 tests in `CometJsonExpressionSuite` pass.



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