yihua commented on code in PR #13208:
URL: https://github.com/apache/hudi/pull/13208#discussion_r2055556188
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/common/table/read/TestHoodieFileGroupReaderOnSpark.scala:
##########
@@ -270,6 +272,46 @@ class TestHoodieFileGroupReaderOnSpark extends
TestHoodieFileGroupReaderBase[Int
assertEquals(expectedOrderingValue,
metadataMap.get(HoodieReaderContext.INTERNAL_META_ORDERING_FIELD))
}
+
+ @Test
+ def getRecordKeyFromMetadataFields(): Unit = {
+ val reader = Mockito.mock(classOf[SparkParquetReader])
+ val tableConfig = Mockito.mock(classOf[HoodieTableConfig])
+ val storageConf = Mockito.mock(classOf[StorageConfiguration[_]])
+ when(tableConfig.populateMetaFields()).thenReturn(true)
+ val sparkReaderContext = new
SparkFileFormatInternalRowReaderContext(reader, Seq.empty, Seq.empty,
storageConf, tableConfig)
+ val schema = SchemaBuilder.builder()
+ .record("test")
+ .fields()
+ .requiredString(HoodieRecord.RECORD_KEY_METADATA_FIELD)
+ .optionalString("field2")
+ .endRecord()
+ val key = "my_key"
+ val row = InternalRow.fromSeq(Seq(UTF8String.fromString(key),
UTF8String.fromString("value2")))
+ assertEquals(key, sparkReaderContext.getRecordKey(row, schema))
+ }
+
+ @Test
+ def getRecordKeyWithKeyGen (): Unit = {
Review Comment:
```suggestion
def getRecordKeyWithKeyGen(): Unit = {
```
##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HiveHoodieReaderContext.java:
##########
@@ -125,6 +127,11 @@ private void setSchemas(JobConf jobConf, Schema
dataSchema, Schema requiredSchem
.stream().map(f ->
String.valueOf(dataSchema.getField(f.name()).pos())).collect(Collectors.joining(",")));
}
+ @Override
+ protected String getKeyGenClass(HoodieTableConfig tableConfig) {
+ throw new UnsupportedOperationException("KeyGen classes are not available
in the Hive reader.");
Review Comment:
nit: use `HoodieNotSupportedException`
--
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]