This is an automated email from the ASF dual-hosted git repository.

leesf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new bd1d2d4  [MINOR] Add avro schema evolution test with (non)nullable 
column and with(out) default value (#3639)
bd1d2d4 is described below

commit bd1d2d4952e2664e2049e79ac571578cddca4500
Author: Sagar Sumit <[email protected]>
AuthorDate: Fri Sep 10 19:33:35 2021 +0530

    [MINOR] Add avro schema evolution test with (non)nullable column and 
with(out) default value (#3639)
---
 .../java/org/apache/hudi/avro/TestHoodieAvroUtils.java   | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git 
a/hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroUtils.java 
b/hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroUtils.java
index 8887cfe..6f5fe92 100644
--- a/hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroUtils.java
+++ b/hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroUtils.java
@@ -46,8 +46,10 @@ public class TestHoodieAvroUtils {
       + "{\"name\": \"timestamp\",\"type\": \"double\"},{\"name\": 
\"_row_key\", \"type\": \"string\"},"
       + "{\"name\": \"non_pii_col\", \"type\": \"string\"},"
       + "{\"name\": \"pii_col\", \"type\": \"string\", \"column_category\": 
\"user_profile\"},"
-      + "{\"name\": \"new_col1\", \"type\": \"string\", \"default\": 
\"dummy_val\"},"
-      + "{\"name\": \"new_col2\", \"type\": [\"int\", \"null\"]}]}";
+      + "{\"name\": \"new_col_not_nullable_default_dummy_val\", \"type\": 
\"string\", \"default\": \"dummy_val\"},"
+      + "{\"name\": \"new_col_nullable_wo_default\", \"type\": [\"int\", 
\"null\"]},"
+      + "{\"name\": \"new_col_nullable_default_null\", \"type\": [\"null\" 
,\"string\"],\"default\": null},"
+      + "{\"name\": \"new_col_nullable_default_dummy_val\", \"type\": 
[\"string\" ,\"null\"],\"default\": \"dummy_val\"}]}";
 
   private static String EXAMPLE_SCHEMA = "{\"type\": \"record\",\"name\": 
\"testrec\",\"fields\": [ "
       + "{\"name\": \"timestamp\",\"type\": \"double\"},{\"name\": 
\"_row_key\", \"type\": \"string\"},"
@@ -111,8 +113,10 @@ public class TestHoodieAvroUtils {
     rec.put("timestamp", 3.5);
     Schema schemaWithMetadata = HoodieAvroUtils.addMetadataFields(new 
Schema.Parser().parse(EVOLVED_SCHEMA));
     GenericRecord rec1 = HoodieAvroUtils.rewriteRecord(rec, 
schemaWithMetadata);
-    assertEquals(rec1.get("new_col1"), "dummy_val");
-    assertNull(rec1.get("new_col2"));
+    assertEquals(rec1.get("new_col_not_nullable_default_dummy_val"), 
"dummy_val");
+    assertNull(rec1.get("new_col_nullable_wo_default"));
+    assertNull(rec1.get("new_col_nullable_default_null"));
+    assertEquals(rec1.get("new_col_nullable_default_dummy_val"), "dummy_val");
     assertNull(rec1.get(HoodieRecord.RECORD_KEY_METADATA_FIELD));
   }
 
@@ -124,8 +128,8 @@ public class TestHoodieAvroUtils {
     rec.put("pii_col", "val2");
     rec.put("timestamp", 3.5);
     GenericRecord rec1 = HoodieAvroUtils.rewriteRecord(rec, new 
Schema.Parser().parse(EVOLVED_SCHEMA));
-    assertEquals(rec1.get("new_col1"), "dummy_val");
-    assertNull(rec1.get("new_col2"));
+    assertEquals(rec1.get("new_col_not_nullable_default_dummy_val"), 
"dummy_val");
+    assertNull(rec1.get("new_col_nullable_wo_default"));
   }
 
   @Test

Reply via email to