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



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java
##########
@@ -70,48 +71,42 @@ public TableSchemaResolver(HoodieTableMetaClient 
metaClient) {
     this.hasOperationField = hasOperationField();
   }
 
+  private Option<MessageType> getTableParquetSchemaFromDataFile() {
+    String dataFilePath = getValidDataFilePath().orElseThrow(() -> new 
IllegalArgumentException(
+        "Could not find any data file written for commit, so could not get 
schema for table "
+            + metaClient.getBasePath()));
+    return getTableParquetSchemaFromDataFile(dataFilePath);
+  }
+
   /**
    * Gets the schema for a hoodie table. Depending on the type of table, read 
from any file written in the latest
    * commit. We will assume that the schema has not changed within a single 
atomic write.
    *
-   * @return Parquet schema for this table
+   * @return Parquet schema for this table, or {@code Option.empty()} if read 
from the log file has no {@code HoodieDataBlock}
    */
-  private MessageType getTableParquetSchemaFromDataFile() {
-    HoodieActiveTimeline activeTimeline = metaClient.getActiveTimeline();
-    Option<Pair<HoodieInstant, HoodieCommitMetadata>> instantAndCommitMetadata 
=
-        activeTimeline.getLastCommitMetadataWithValidData();
+  private Option<MessageType> getTableParquetSchemaFromDataFile(@Nonnull 
String filePath) {

Review comment:
       why here we need @Nonnull annotation, i do not see the annotation in 
other methods/fields




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