voonhous commented on code in PR #17659:
URL: https://github.com/apache/hudi/pull/17659#discussion_r2678549009
##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/realtime/HoodieMergeOnReadTableInputFormat.java:
##########
@@ -419,14 +420,19 @@ private static Option<HoodieVirtualKeyInfo>
getHoodieVirtualKeyInfo(HoodieTableM
}
TableSchemaResolver tableSchemaResolver = new
TableSchemaResolver(metaClient);
try {
- Schema schema = tableSchemaResolver.getTableAvroSchema();
- boolean isNonPartitionedKeyGen =
StringUtils.isNullOrEmpty(tableConfig.getPartitionFieldProp());
+ HoodieSchema schema = tableSchemaResolver.getTableSchema();
+ String partitionFieldProp = tableConfig.getPartitionFieldProp();
+ boolean isNonPartitionedKeyGen =
StringUtils.isNullOrEmpty(partitionFieldProp);
return Option.of(
new HoodieVirtualKeyInfo(
tableConfig.getRecordKeyFieldProp(),
- isNonPartitionedKeyGen ? Option.empty() :
Option.of(tableConfig.getPartitionFieldProp()),
- schema.getField(tableConfig.getRecordKeyFieldProp()).pos(),
- isNonPartitionedKeyGen ? Option.empty() :
Option.of(schema.getField(tableConfig.getPartitionFieldProp()).pos())));
+ isNonPartitionedKeyGen ? Option.empty() :
Option.of(partitionFieldProp),
+ schema.getField(tableConfig.getRecordKeyFieldProp())
+ .orElseThrow(() -> new HoodieSchemaException("Field: " +
partitionFieldProp + " not found"))
Review Comment:
Good catch! Done
##########
hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java:
##########
@@ -476,10 +367,10 @@ public Option<String>
getTableHistorySchemaStrFromCommitMetadata() {
*/
public boolean hasOperationField() {
try {
- Schema tableAvroSchema = getTableAvroSchemaFromDataFile();
- return tableAvroSchema.getField(HoodieRecord.OPERATION_METADATA_FIELD)
!= null;
+ HoodieSchema tableSchema = getTableSchemaFromDataFile();
+ return
tableSchema.getField(HoodieRecord.OPERATION_METADATA_FIELD).isPresent();
} catch (Exception e) {
- LOG.info("Failed to read operation field from avro schema ({})",
e.getMessage());
+ LOG.info("Failed to read operation field from hoodie schema ({})",
e.getMessage());
Review Comment:
Done
--
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]