1
0

[HUDI-3936] Fix projection for a nested field as pre-combined key (#5379)

This PR fixes the projection logic around a nested field which is used as the pre-combined key field. The fix is to only check and append the root level field for projection, i.e., "a", for a nested field "a.b.c" in the mandatory columns.

- Changes the logic to check and append the root level field for a required nested field in the mandatory columns in HoodieBaseRelation.appendMandatoryColumns
This commit is contained in:
Y Ethan Guo
2022-04-21 17:17:57 -07:00
committed by GitHub
parent 037f89ee7c
commit c4bc2deea0
8 changed files with 66 additions and 34 deletions

View File

@@ -257,6 +257,13 @@ public class TestHoodieAvroUtils {
assertEquals(expectedSchema, rec1.getSchema());
}
@Test
public void testGetRootLevelFieldName() {
assertEquals("a", HoodieAvroUtils.getRootLevelFieldName("a.b.c"));
assertEquals("a", HoodieAvroUtils.getRootLevelFieldName("a"));
assertEquals("", HoodieAvroUtils.getRootLevelFieldName(""));
}
@Test
public void testGetNestedFieldVal() {
GenericRecord rec = new GenericData.Record(new Schema.Parser().parse(EXAMPLE_SCHEMA));