Davis-Zhang-Onehouse opened a new pull request, #20803:
URL: https://github.com/apache/hudi/pull/20803

   ### Describe the issue this Pull Request addresses
   
   issue: #20802
   Part of #20683, RFC-118 (#20684).
   Stacked on #20801: review only the last commit. Until the PRs below it 
merge, this PR also shows their commits.
   
   The rows of an embedding table depend on how their inputs were prepared: the 
preprocessor each file extension maps to, the tokenizer, the chunking, PDF, 
image, video and audio settings, the logic of each preparation step and the JDK 
release. A job with different settings or a different build that writes into an 
existing table would mix rows prepared two ways, and nothing refuses it.
   
   An embedding column is also tied to one model. Two rounds configured with 
different models for the same column could both commit rows into it unless the 
model identity is recorded with the table and checked inside the data commit, 
including when publishing that record failed after an earlier commit.
   
   ### Summary and Changelog
   
   An embedding table records its preparation contract and the model identity 
of each VECTOR column, and a job that does not match them is refused before it 
prepares or commits anything.
   
   - Preparation contract (`PrepLogicVersions`): table properties under 
`hoodie.table.embedding.prep.`, written when the table is created: 
`<kind>.logic.version` for text, image, video and audio (the format 
`prep-logic-v3` plus the logic constants of the code that prepares that kind, 
among them the tokenizer encoding, text normalizer, JCodec and FFmpeg keyframe 
logic and Whisper transcription), each output-changing setting at its effective 
value with defaults included (stored as `hoodie.table.embedding.prep.<name>`, 
for example `chunk.max.tokens`), `extension.<ext>` (preprocessor class and 
versioned name), `tokenizer.id`, `tokenizer.class` and 
`java.specification.version`. Performance settings, implementation-class keys 
and the input size caps are not pinned.
   - Checks: a job is compared key by key on the kinds it prepares and refused 
with each mismatching key and both values. A setting the table does not store 
compares as its default and an extension as its default mapping; a logic 
version, tokenizer or JDK release the table does not store is refused. An 
unrecognized key under the chunk, PDF or prep prefixes is refused at job start. 
`PrepRound` carries the driver's contract to executors, where 
`PreprocessingIterator` checks it before reading any file and stamps every 
prepared row with its kind's version in the `prep_logic_version` aux entry.
   - Source contract (`UnstructuredSourceContract`): `embeddingTablePins` adds 
the column-info layout version and the preparation contract to the embedding 
table's pins. A prepared job and a checked table are reused while their 
properties are unchanged.
   - Model identity (`EmbeddingColumnInfoStore`, `EmbeddingColumnInfoConfig`): 
each VECTOR column's identity (provider, model name, dimension, optional 
provider revision, input-transform version) is kept as an event history in 
`.hoodie/.aux/embedding-column-info.json`, with a commit-time fence in 
`.hoodie/.aux/embedding-column-fence.json`. The start check is read-only and 
refuses a different model on an existing column, a retired name configured 
again and invalid retirements. `EmbeddingTableTransformer.onPreCommit` rechecks 
the round against the identities committed meanwhile and replaces the fence 
inside the data commit, refusing a conflict with 
`HoodiePreCommitRefusalException` before the instant completes; `onCommit` 
publishes the fence's committed state to the history file after the table 
commit. A fence candidate counts only once its instant completed, and a missing 
history is restored from a committed fence.
   - Atomic replacement (`EmbeddingColumnInfoAtomicSwap`): local files use a 
NIO atomic move on raw local storage (a checksum sidecar is refused), HDFS an 
overwrite rename, S3A and GCS an output stream that advertises 
`fs.capability.outputstream.abortable` (probed on a temporary object first). A 
failed upload is aborted rather than closed, and the abort's cleanup result is 
checked. Other storage schemes are refused.
   - New config keys: `hoodie.unstructured.embedding.retire.columns` (VECTOR 
columns to retire after a successful round; a retired name cannot be configured 
again) and `hoodie.unstructured.embedding.model.<alias>.version` 
(provider-exposed model revision).
   - RFC-100 states that the input size caps are not part of a table's stored 
prep contract.
   - 37 test files, among them `TestPrepLogicVersions`, 
`TestEmbeddingColumnInfoStore`, `TestEmbeddingColumnInfoRound`, 
`TestEmbeddingColumnInfoAtomicSwap`, `TestUnstructuredSourceContract`, 
`TestUnstructuredKeyEncoding` and `TestBlobReferencePathVersion`, plus a golden 
file of a default job's stored prep contract 
(`prep-default-table-properties.txt`).
   
   Existing files touched: `rfc/rfc-100/rfc-100.md`.
   
   No code was copied from other projects.
   
   ### Impact
   
   Embedding tables carry new table properties, and a job whose preparation 
contract or model identity does not match the table is refused before anything 
is prepared, naming the keys that differ. Two new embedding config keys. Every 
embedding data commit that has a model identity replaces one small fence file 
inside the commit. Existing Hudi behaviour outside the unstructured ingestion 
path is unchanged.
   
   ### Risk Level
   
   medium: the change adds persisted table properties, auxiliary metadata files 
with storage-specific atomic replacement, and a check inside the data commit. 
Covered by `TestPrepLogicVersions`, `TestEmbeddingColumnInfoStore`, 
`TestEmbeddingColumnInfoRound`, `TestEmbeddingColumnInfoAtomicSwap` and 
`TestUnstructuredSourceContract`; module compile, checkstyle and RAT on JDK 11 
/ Spark 3.5 / Scala 2.12; GitHub Java CI runs on the stack tip.
   
   ### Documentation Update
   
   The new config keys carry their config documentation (`.withDocumentation` 
on `RETIRE_COLUMNS` and `MODEL_VERSION`). A website page follows once the chain 
lands.
   
   ### 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]

Reply via email to