rahil-c commented on code in PR #17573:
URL: https://github.com/apache/hudi/pull/17573#discussion_r2624204110


##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/spark/sql/avro/HoodieSparkSchemaConverters.scala:
##########
@@ -102,7 +102,14 @@ object HoodieSparkSchemaConverters {
           val fields = st.map { f =>
             val fieldSchema = toHoodieType(f.dataType, f.nullable, f.name, 
childNameSpace)
             val doc = f.getComment.orNull
-            HoodieSchemaField.of(f.name, fieldSchema, doc)
+            // Match existing Avro SchemaConverters behavior: use NULL_VALUE 
for nullable unions
+            // to avoid serializing "default":null in JSON representation
+            val defaultVal = if (fieldSchema.isNullable) {
+              HoodieJsonProperties.NULL_VALUE
+            } else {
+              null
+            }
+            HoodieSchemaField.of(f.name, fieldSchema, doc, defaultVal)
           }

Review Comment:
   thanks for catching this, will fix



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

Reply via email to