Davis-Zhang-Onehouse opened a new pull request, #20793: URL: https://github.com/apache/hudi/pull/20793
### Describe the issue this Pull Request addresses issue: #20792 Part of #20683, RFC-118 (#20684). Stacked on #20791: review only the last commit. Until the PRs below it merge, this PR also shows their commits. Some Hudi Streamer sources depend on settings of the job that reads them: required job properties, transformers that must run, properties of the table they create, and checks on the target table and schema. The streamer has no place for a source to state these, so a misconfigured job is only found once the source reads input or the write fails. ### Summary and Changelog A Hudi Streamer source can declare a contract that prepares and checks its job before the source is built; sources without one run exactly as without contracts. - New `SourceContract` interface (hudi-utilities): `prepareJob`, `isPreparedJob`, `tableProperties`, `transformerChain`, `checkTable` and `checkJob`, all no-ops by default except `prepareJob`. - New `SourceContracts` registry, keyed by source class and covering subclasses, with `SourceContracts.NONE` for a source that registers none. The registry is empty in this change. - `HoodieStreamer.StreamSyncService` prepares the job through the contract once, before it builds its schema provider and validates an existing table, and calls `checkTable` before `HoodieWriterUtils.validateTableConfig`. - `StreamSync` runs `checkTable`, the contract's transformer chain and `checkJob` (with the target schema and the table schema without meta columns) before it builds the source, passes the contract to the source through `StreamContext.getSourceContract()`, and persists the contract's `tableProperties()` when it creates a table. - `HoodieTableMetaClient.TableBuilder.setAdditionalProperties(Properties)` carries caller-owned properties into a new table; the builder's own settings take precedence for keys it also writes. - `StreamContext.getSourceContract()` (default `NONE`) and a `DefaultStreamContext` field and constructor carry the contract. - Tests: `TestSourceContracts`, `TestStreamSyncSourceContract`, `TestStreamSyncStockSourceContext`, and a new case in `TestHoodieTableMetaClient`. Existing files touched: `HoodieTableMetaClient.java`, `DefaultStreamContext.java`, `HoodieStreamer.java`, `StreamContext.java`, `StreamSync.java`, and test `TestHoodieTableMetaClient.java`. No code was copied from other projects. 4 test files. ### Impact Adds the public `SourceContract` and `SourceContracts` types, `StreamContext.getSourceContract()` and `TableBuilder.setAdditionalProperties`. No source registers a contract here, so existing Streamer jobs see unchanged properties, transformers, table properties and source context. ### Risk Level low: every source resolves to the no-op `SourceContracts.NONE`, and the stock source context is passed through unchanged, which `TestStreamSyncStockSourceContext` covers. ### 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 -- 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]
