Skip to content

[rust] Hash-distribute log-table appends by declared bucket key#3643

Open
fresh-borzoni wants to merge 2 commits into
apache:mainfrom
fresh-borzoni:fix-log-append-bucket-key-hashing
Open

[rust] Hash-distribute log-table appends by declared bucket key#3643
fresh-borzoni wants to merge 2 commits into
apache:mainfrom
fresh-borzoni:fix-log-append-bucket-key-hashing

Conversation

@fresh-borzoni

@fresh-borzoni fresh-borzoni commented Jul 14, 2026

Copy link
Copy Markdown
Member

closes #3644

Log tables with a declared bucket key weren't hashing appends by it and every row in a flush landed in one bucket (sticky), unlike the KV/upsert path and the Java client, so bucket-key co-location was silently broken.

Now the append path hashes by the bucket key like Java: append(row) hashes each row, and append_arrow_batch splits a batch across buckets (single-bucket batches send as-is, mixed batches fan out per bucket).

Tables without a bucket key are unchanged.

@fresh-borzoni

Copy link
Copy Markdown
Member Author

@charlesdong1991 @leekeiabstraction PTAL 🙏

@fresh-borzoni
fresh-borzoni force-pushed the fix-log-append-bucket-key-hashing branch 2 times, most recently from 5793b64 to 5616a40 Compare July 14, 2026 03:17
@fresh-borzoni
fresh-borzoni force-pushed the fix-log-append-bucket-key-hashing branch from 5616a40 to 3adea9e Compare July 15, 2026 13:15

@charlesdong1991 charlesdong1991 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! I left two nit comments

Comment on lines +202 to +203
let row = ColumnarRow::new(Arc::clone(&batch_arc), Arc::clone(&row_type), i, None)?;
let (bucket, key) = router.bucket_of(&row, num_buckets)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it might not be very efficient when row numbers are large given this will do full typed-batch builds on each iteration, because it will also downcast each column? maybe can utilize set_row_id in ColumnarRow and move the cursor instead?

return self.send_arrow_batch(batch, physical_table_path, None);
};
if batch.num_rows() == 0 {
return self.send_arrow_batch(batch, physical_table_path, None);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so empty batch will result in sticky assigner, but if the first batch is empty, will this mistake all following keyed appends?

maybe we can add a test to see how it behaves?

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.

[rust] Log-table appends ignore the declared bucket key

2 participants