harshmotw-db commented on code in PR #48770:
URL: https://github.com/apache/spark/pull/48770#discussion_r1831618194


##########
sql/api/src/main/scala/org/apache/spark/sql/util/ArrowUtils.scala:
##########
@@ -146,19 +146,33 @@ private[sql] object ArrowUtils {
           ArrowType.Struct.INSTANCE,
           null,
           Map("variant" -> "true").asJava)
+        val metadataFieldType = new FieldType(
+          false,
+          toArrowType(BinaryType, timeZoneId, largeVarTypes),
+          null,
+          Map("variant" -> "true").asJava
+        )
         new Field(
           name,
           fieldType,
           Seq(
             toArrowField("value", BinaryType, false, timeZoneId, 
largeVarTypes),
-            toArrowField("metadata", BinaryType, false, timeZoneId, 
largeVarTypes)).asJava)
+            new Field("metadata", metadataFieldType, 
Seq.empty[Field].asJava)).asJava)
       case dataType =>
         val fieldType =
           new FieldType(nullable, toArrowType(dataType, timeZoneId, 
largeVarTypes), null)
         new Field(name, fieldType, Seq.empty[Field].asJava)
     }
   }
 
+  def isVariantField(field: Field): Boolean = {
+    assert(field.getType.isInstanceOf[ArrowType.Struct])

Review Comment:
   It should be an assert since the 
[callsite](https://github.com/apache/spark/blob/876d5cab7ffeb55b86516350af23aca8cae35afe/sql/api/src/main/scala/org/apache/spark/sql/util/ArrowUtils.scala#L187)
 already checks for struct.



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