YannByron commented on a change in pull request #4773:
URL: https://github.com/apache/hudi/pull/4773#discussion_r807566764
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java
##########
@@ -477,11 +477,30 @@ public boolean isHasOperationField() {
private boolean hasOperationField() {
try {
- Schema tableAvroSchema = getTableAvroSchemaFromDataFile();
- return tableAvroSchema.getField(HoodieRecord.OPERATION_METADATA_FIELD)
!= null;
+ Option<String> anyDataFilePath = getAnyDataFilePathFromLastCommit();
+ if (anyDataFilePath.isPresent()) {
+ Schema tableAvroSchema =
getTableAvroSchemaFromDataFile(anyDataFilePath.get());
+ return tableAvroSchema.getField(HoodieRecord.OPERATION_METADATA_FIELD)
!= null;
+ } else {
+ LOG.info("No data file found from last commit");
+ return false;
+ }
} catch (Exception e) {
LOG.warn("Failed to read operation field from avro schema", e);
return false;
}
}
+
+ private Option<String> getAnyDataFilePathFromLastCommit() {
Review comment:
maybe `getValidDataFilePath` is ok.
--
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]