vinishjail97 opened a new pull request, #18637:
URL: https://github.com/apache/hudi/pull/18637

   ### Describe the issue this Pull Request addresses
   
   `TableSchemaResolver.hasOperationField` is lazily initialized by calling 
`hasOperationField()`, which calls `getTableAvroSchemaFromDataFile()`. That 
path walks completed commits in reverse via 
`getLatestCommitWithInsertOrUpdate()` looking for a commit with 
inserts/updates, reading each commit's metadata file along the way. For tables 
with a long tail of empty commits this is an expensive sequential I/O on object 
stores, paid every time a `TableSchemaResolver` is created.
   
   ### Summary and Changelog
   
   Resolve the flag directly from the table config key 
`hoodie.allow.operation.metadata.field` (default `false`) instead of inspecting 
a data file. The writer consults the same key 
(`HoodieWriteConfig.ALLOW_OPERATION_METADATA_FIELD`) when deciding whether to 
populate the field, so this is authoritative for tables created by Hudi. The 
public `hasOperationField()` method is left intact — its javadoc already says 
it is for test use only.
   
   ### Impact
   
   For tables with N empty commits before the latest insert/update, the 
cold-path schema resolution drops from N+ commit-metadata reads to zero 
data-file reads. No behavioral change for tables that don't use the operation 
metadata field (the common case). Tables that explicitly set 
`hoodie.allow.operation.metadata.field=true` in `hoodie.properties` continue to 
get `_hoodie_operation` added to the resolved schema by 
`addMetadataFields(...)`.
   
   ### Risk Level
   
   low
   
   Single-file diff scoped to one lazy initializer in `TableSchemaResolver`. 
The constructor's behavior is now O(1) and side-effect free. Existing tests 
covering `hasOperationField()` still exercise the data-file inspection path 
because the public method is unchanged.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   - [ ] CI passed


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