fix(table): move rows to their new bucket when UPDATE changes the bucket key #1319
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 460 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.367
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1319"
general
weight: 0.35
JeonDaehong
Purpose
Linked issue: close #1318
On a fixed-bucket append table (
'bucket' = 'N','bucket-key' = '...'),UPDATEor a matchedMERGE INTOupdate that changes a bucket-key column leaves the row in the bucket of its old value. Scans prune buckets by the bucket-key hash, so any query filtering on the new value skips the row, while a full scan still returns it.Before this change, on main:
After:
The table is
CREATE TABLE db.orders (id INT, customer STRING, amount INT) WITH ('bucket' = '4', 'bucket-key' = 'customer')with rows(1, 'alice', 10), (2, 'bob', 20), (3, 'carol', 30), (4, 'dave', 40). Before the fix,orders$filesshows the rewritten file still inbucket-2(wherealicehashes), while a newINSERTof'erin'goes tobucket-1.Brief change log
CopyOnWriteMergeWriter::prepare_commit: when the updated columns include abucket-keycolumn and the table has a fixed bucket count above 1, compute the bucket of each rewritten row with the table's bucket function and bucket count, asTableWritedoes for inserts, and write each bucket's rows into that bucket. The deleted file stays in the commit message of its original bucket; rows that moved are added in the message of their new bucket.This matches Java: Spark's
UPDATEon an append table writes the updated rows throughPaimonSparkWriter, which assignsHASH_FIXEDbuckets from the bucket keys of each row.Assumptions worth checking:
bucketoption.TableWriteuses it too, and the commit records it as the files' total bucket count. A partition still holding files with an older bucket count (rescaled without overwrite) gets the rewritten rows hashed with the current count.Tests
update_tests::test_update_bucket_key_moves_row_to_new_bucket: UPDATE of the bucket key, then a filter on the new value returns the row.append_merge_into::test_update_bucket_key_moves_row_to_new_bucket: the same throughMERGE INTO, with one updated row moving out of a file that also keeps an unchanged row.cow_writer.rs, both tests fail with the filtered query returning[]instead of the updated rows.RUST_MIN_STACK=16777216 cargo test -p paimon-datafusion --test update_tests --test append_merge_into --test delete_tests --test merge_into_tests(21, 35, 25 and 29 tests) pass.cargo fmt --all -- --checkandcargo clippy --locked -p paimon -p paimon-datafusion --all-targets -- -D warningspass.NULL,'bucket-function.type' = 'mod', and a MERGE mixing matched DELETE, matched UPDATE and NOT MATCHED INSERT.The full
paimonunit-test suite and the vortex feature are left to CI.API and Format
No API or storage format change.
Documentation
No.