Skip to content

[HUDI-9666] Auto-deduce ComplexKeyGenerator single-field record-key encoding on branch-0.x#19305

Open
ad1happy2go wants to merge 1 commit into
apache:branch-0.xfrom
ad1happy2go:complex-keygen-fix-branch-0x
Open

[HUDI-9666] Auto-deduce ComplexKeyGenerator single-field record-key encoding on branch-0.x#19305
ad1happy2go wants to merge 1 commit into
apache:branch-0.xfrom
ad1happy2go:complex-keygen-fix-branch-0x

Conversation

@ad1happy2go

Copy link
Copy Markdown
Collaborator

Change Logs

For a ComplexKeyGenerator with a single record-key field, the _hoodie_record_key encoding changed across releases (HUDI-7001): 0.14.0 and older wrote field:value, while 0.14.1/0.15.0/1.0.0–1.0.2 wrote the bare value. A table written by one release and then written by another silently mixes both formats, so upserts stop matching existing records and create duplicates.

The current guard (#17834) fails all single-field complex-keygen writes by default until the user manually picks an encoding via hoodie.write.complex.keygen.new.encoding. This PR makes the writer self-healing instead:

  • Auto-deduction (new config hoodie.write.complex.keygen.auto.deduce.encoding, default true): on write initialization, read one stored _hoodie_record_key from an existing base file, detect the table's actual encoding, and pin it on the write config so upserts keep matching.
  • Caching: the deduced value is stored in .hoodie/.aux/complex_key_encoding; subsequent writes read the cache instead of the parquet footer.
  • New/empty tables: default to the new encoding (bare value) instead of failing the first write.
  • The validation guard still applies when auto-deduction is explicitly disabled; readers are never affected.

Impact

Single-field ComplexKeyGenerator writes work out of the box across upgrades (no manual encoding config, no failed pipelines), while preserving the existing table's key format and preventing duplicate records.

Risk level

medium

Verified by three new functional test suites (auto-deduction of both encodings, existing-table upgrade safe/danger paths, new-table defaults). Also validated end-to-end with bundle jars against tables created by genuine 0.14.0 (field:value) and 0.14.1 (bare value) releases: encoding detected and preserved, 100/100 records upserted in place, zero duplicates.

Documentation Update

Config docs for hoodie.write.complex.keygen.new.encoding, hoodie.write.complex.keygen.auto.deduce.encoding, and hoodie.write.complex.keygen.validation.enable are updated in HoodieWriteConfig. The deployment-guide section on the complex key generator should be updated to mention auto-deduction as the default behavior.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

🤖 Generated with Claude Code

…ncoding on branch-0.x

For a ComplexKeyGenerator with a single record-key field, the
_hoodie_record_key encoding changed across releases (HUDI-7001):
0.14.0 and older wrote field:value, while 0.14.1/0.15.0 wrote the bare
value. Mixing writers silently mixes both formats, so upserts stop
matching existing records and create duplicates.

The existing guard (apache#17834) fails all single-field complex-keygen
writes by default until the user manually picks an encoding. This
change makes the writer self-healing instead:

- New config hoodie.write.complex.keygen.auto.deduce.encoding
  (default true): on write initialization, read one stored
  _hoodie_record_key from an existing base file, detect the table's
  actual encoding, and pin it on the write config.
- The deduced value is cached in .hoodie/.aux/complex_key_encoding.
- New/empty tables default to the new encoding instead of failing the
  first write.
- The validation guard still applies when auto-deduction is disabled;
  readers are never affected.

Adds three functional test suites covering auto-deduction of both
encodings, the existing-table upgrade safe/danger paths, and new-table
defaults.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ad1happy2go
ad1happy2go force-pushed the complex-keygen-fix-branch-0x branch from a83d686 to aeb6e8c Compare July 16, 2026 09:03
@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants