leesf commented on a change in pull request #4773:
URL: https://github.com/apache/hudi/pull/4773#discussion_r812500022



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java
##########
@@ -166,11 +165,10 @@ public Schema getTableAvroSchema(boolean 
includeMetadataFields) throws Exception
         return schemaFromTableConfig.get();
       }
     }
-    if (includeMetadataFields) {
-      return getTableAvroSchemaFromDataFile();
-    } else {
-      return 
HoodieAvroUtils.removeMetadataFields(getTableAvroSchemaFromDataFile());
-    }
+
+    return getTableAvroSchemaFromDataFile()
+        .map(avroSchema -> includeMetadataFields ? avroSchema : 
HoodieAvroUtils.removeMetadataFields(avroSchema))
+        .orElseThrow(() -> new HoodieException("Failed to get table avro 
schema"));

Review comment:
       here why we need throw exception? there is no logic before.




-- 
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]


Reply via email to