yihua opened a new pull request, #20883: URL: https://github.com/apache/hudi/pull/20883
### Describe the issue this Pull Request addresses closes #20882 A non-native table format may keep per-row metadata in its data files, such as row lineage, that it derives from a row's position in the file. When Hudi rewrites a base file (merge, small-file concat, compaction, clustering), the rows it carries over land at new positions, so the format loses their values, and the `HoodieTableFormat` SPI has no way to declare or supply them. ### Summary and Changelog Stacked on #20877 (notify the pluggable table format on compaction completion), review that first; the compaction tests here need it. The update-as-delete-insert mode of #20167 does not yet keep these columns for a record its update moves to another file group; until that follow-up lands, whichever of the two PRs merges second makes the mode refuse a format that declares columns. `HoodieTableFormat#getFormatMetaColumns` (empty by default) lets a table format declare per-row metadata columns. Each `FormatMetaColumn` gives its field, the value a record written as new or changed gets (`valueOnWrite`), the value a changed version of a carried-over record gets (`valueOnUpdate`, defaults to `valueOnWrite`), and a `BaseFileColumnResolver` that resolves the value of a carried-over record from its position in the base file and its stored value. The columns follow the rule of the Hudi meta fields: `FormatMetaColumnHandler` resolves them in the file group reader (before any filter) and in the concat handle, and the merge handle sets them on the records it writes as new or changed; the columns are stored after the table columns and stay out of the table schema. Rewrites that cannot carry them over fail instead of dropping them (see the limitations below). The test table format declares row lineage columns and a first-instant column, covered through Java and Spark copy -on-write upserts, merge-on-read compaction and clustering. Limitations a format author will hit: - Only nullable long or int columns can be declared (never supported: other types). - Flink copy-on-write upserts, Flink compaction and Flink clustering refuse a format that declares columns (never supported). - The sorted, change-log and other non file-group-reader merge handles, binary/stream-copy and single-job Spark clustering refuse it (never supported). - Reads of part of a base file, bootstrap base files and schema evolution on read refuse it (never supported). - A custom Java clustering strategy has to call `setFormatMetaColumnsWriteSchema` on its group write config, or the values are dropped. ### Impact New SPI methods on `HoodieTableFormat`, `RecordContext#setValue` (Avro and Spark implementations), and a new `HoodieFileGroupReader` builder option. No change for the native format or any table format that does not declare format meta columns. ### Risk Level low. Every new path is gated on a table format declaring format meta columns; the default list is empty. ### Documentation Update none ### Contributor's checklist - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [ ] Enough context is provided in the sections above - [ ] Adequate tests were added if applicable -- 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]
