zhangyue19921010 commented on a change in pull request #4782:
URL: https://github.com/apache/hudi/pull/4782#discussion_r806336043
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java
##########
@@ -115,6 +117,21 @@ private MessageType getTableParquetSchemaFromDataFile() {
}
}
+ private MessageType readSchemaFromBaseFile(String filePath) throws
IOException {
+ if (filePath.contains(HoodieFileFormat.PARQUET.getFileExtension())) {
+ // this is a parquet file
+ return readSchemaFromParquetBaseFile(new Path(filePath));
+ } else if (filePath.contains(HoodieFileFormat.HFILE.getFileExtension())) {
+ // this is a HFile
+ return readSchemaFromHFileBaseFile(new Path(filePath));
+ } else if (filePath.contains(HoodieFileFormat.ORC.getFileExtension())) {
+ // this is a ORC file
+ return readSchemaFromORCBaseFile(new Path(filePath));
+ } else {
+ throw new IllegalArgumentException("Unknown base file format :" +
filePath);
+ }
Review comment:
Okay, will create a related tickets to unify BaseFileUtils and also
improve UTs ASAP.
Thanks a lot for your review :)
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java
##########
@@ -115,6 +117,21 @@ private MessageType getTableParquetSchemaFromDataFile() {
}
}
+ private MessageType readSchemaFromBaseFile(String filePath) throws
IOException {
+ if (filePath.contains(HoodieFileFormat.PARQUET.getFileExtension())) {
+ // this is a parquet file
+ return readSchemaFromParquetBaseFile(new Path(filePath));
+ } else if (filePath.contains(HoodieFileFormat.HFILE.getFileExtension())) {
+ // this is a HFile
+ return readSchemaFromHFileBaseFile(new Path(filePath));
+ } else if (filePath.contains(HoodieFileFormat.ORC.getFileExtension())) {
+ // this is a ORC file
+ return readSchemaFromORCBaseFile(new Path(filePath));
+ } else {
+ throw new IllegalArgumentException("Unknown base file format :" +
filePath);
+ }
Review comment:
https://issues.apache.org/jira/browse/HUDI-3428
--
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]