lw309637554 commented on a change in pull request #2125: URL: https://github.com/apache/hudi/pull/2125#discussion_r496831803
########## File path: hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java ########## @@ -175,20 +175,45 @@ public MessageType getTableParquetSchema() throws Exception { * @throws Exception */ public Schema getTableAvroSchemaWithoutMetadataFields() throws Exception { - Option<Schema> schemaFromCommitMetadata = getTableSchemaFromCommitMetadata(false); + HoodieTimeline timeline = metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants(); + Option<Schema> schemaFromCommitMetadata = getTableSchemaFromCommitMetadata(timeline.lastInstant().get(), false); return schemaFromCommitMetadata.isPresent() ? schemaFromCommitMetadata.get() : HoodieAvroUtils.removeMetadataFields(getTableAvroSchemaFromDataFile()); } + /** + * Gets users data schema for a hoodie table in Avro format of the instant. + * + * @param instant will get the instant data schema + * @return Avro user data schema + * @throws Exception + */ + public Schema getTableAvroSchemaWithoutMetadataFieldsForInstant(HoodieInstant instant) throws Exception { + Option<Schema> schemaFromCommitMetadata = getTableSchemaFromCommitMetadata(instant,false); Review comment: ok ########## File path: hudi-common/src/main/java/org/apache/hudi/common/table/TableSchemaResolver.java ########## @@ -175,20 +175,45 @@ public MessageType getTableParquetSchema() throws Exception { * @throws Exception */ public Schema getTableAvroSchemaWithoutMetadataFields() throws Exception { - Option<Schema> schemaFromCommitMetadata = getTableSchemaFromCommitMetadata(false); + HoodieTimeline timeline = metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants(); + Option<Schema> schemaFromCommitMetadata = getTableSchemaFromCommitMetadata(timeline.lastInstant().get(), false); return schemaFromCommitMetadata.isPresent() ? schemaFromCommitMetadata.get() : HoodieAvroUtils.removeMetadataFields(getTableAvroSchemaFromDataFile()); } + /** + * Gets users data schema for a hoodie table in Avro format of the instant. + * + * @param instant will get the instant data schema + * @return Avro user data schema + * @throws Exception + */ + public Schema getTableAvroSchemaWithoutMetadataFieldsForInstant(HoodieInstant instant) throws Exception { Review comment: 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org