Zouxxyy commented on code in PR #7175:
URL: https://github.com/apache/hudi/pull/7175#discussion_r1019779340


##########
hudi-common/src/test/java/org/apache/hudi/common/model/TestOverwriteNonDefaultsWithLatestAvroPayload.java:
##########
@@ -181,10 +181,10 @@ public void testDeletedRecord() throws IOException {
   @Test
   public void testNullColumn() throws IOException {
     Schema avroSchema = Schema.createRecord(Arrays.asList(
-            new Schema.Field("id", 
Schema.createUnion(Schema.create(Schema.Type.STRING), 
Schema.create(Schema.Type.NULL)), "", JsonProperties.NULL_VALUE),
-            new Schema.Field("name", 
Schema.createUnion(Schema.create(Schema.Type.STRING), 
Schema.create(Schema.Type.NULL)), "", JsonProperties.NULL_VALUE),
-            new Schema.Field("age", 
Schema.createUnion(Schema.create(Schema.Type.STRING), 
Schema.create(Schema.Type.NULL)), "", JsonProperties.NULL_VALUE),
-            new Schema.Field("job", 
Schema.createUnion(Schema.create(Schema.Type.STRING), 
Schema.create(Schema.Type.NULL)), "", JsonProperties.NULL_VALUE)
+            new Schema.Field("id", 
Schema.createUnion(Schema.create(Schema.Type.NULL), 
Schema.create(Schema.Type.STRING)), "", JsonProperties.NULL_VALUE),

Review Comment:
   After avro 1.10, the defaultValue is checked when the Schema is initialized, 
and here are the 
[rules](https://avro.apache.org/docs/1.11.1/specification/#unions) of the union
   
   > Unions, as mentioned above, are represented using JSON arrays. For 
example, ["null", "string"] declares a schema which may be either a null or 
string.
   > (Note that when a default value is specified for a record field whose type 
is a union, **the type of the default value must match the first element of the 
union**. Thus, for unions containing “null”, the “null” is usually listed 
first, since the default value of such unions is typically 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]

Reply via email to