the-other-tim-brown commented on code in PR #13208:
URL: https://github.com/apache/hudi/pull/13208#discussion_r2059150682
##########
hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroReaderContext.java:
##########
@@ -157,16 +157,25 @@ void getFieldNotInSchema() {
}
@Test
- void getRecordKeyWithKeyGen() {
+ void getRecordKeyWithSingleKey() {
when(tableConfig.populateMetaFields()).thenReturn(false);
- BaseKeyGenerator keyGenerator = mock(BaseKeyGenerator.class);
- HoodieAvroReaderContext avroReaderContext = new
HoodieAvroReaderContext(storageConfig, tableConfig, keyGenerator);
- IndexedRecord indexedRecord = createSkeletonRecord("field1", "field2", 3);
+ when(tableConfig.getRecordKeyFields()).thenReturn(Option.of(new
String[]{"skeleton_field_1"}));
+ HoodieAvroReaderContext avroReaderContext = new
HoodieAvroReaderContext(storageConfig, tableConfig);
String recordKey = "record_key";
- when(keyGenerator.getRecordKey((GenericRecord)
indexedRecord)).thenReturn(recordKey);
+ IndexedRecord indexedRecord = createSkeletonRecord(recordKey, "field2", 3);
assertEquals(recordKey, avroReaderContext.getRecordKey(indexedRecord,
SKELETON_SCHEMA));
}
+ @Test
+ void getRecordKeyWithMultipleKeys() {
+ when(tableConfig.populateMetaFields()).thenReturn(false);
+ when(tableConfig.getRecordKeyFields()).thenReturn(Option.of(new
String[]{"base_field_1", "base_field_3.nested_field"}));
+ HoodieAvroReaderContext avroReaderContext = new
HoodieAvroReaderContext(storageConfig, tableConfig);
+ String recordKey = "base_field_1:compound,base_field_3.nested_field:3.2";
+ IndexedRecord indexedRecord = createBaseRecord("compound", "field2", 3.2);
+ assertEquals(recordKey, avroReaderContext.getRecordKey(indexedRecord,
BASE_SCHEMA));
Review Comment:
This could become very challenging to maintain. We can discuss more offline.
--
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]