Skip to content

feat(fuse): add hash-distributed partition writes - #20216

Open
KKould wants to merge 10 commits into
databendlabs:mainfrom
KKould:feat/fuse-hash-write-distribution-v2
Open

feat(fuse): add hash-distributed partition writes#20216
KKould wants to merge 10 commits into
databendlabs:mainfrom
KKould:feat/fuse-hash-write-distribution-v2

Conversation

@KKould

@KKould KKould commented Jul 28, 2026

Copy link
Copy Markdown
Member

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  • Add a stable bucket(count, value) partition transform using SipHash.
  • Add WRITE_DISTRIBUTION_MODE = 'hash' for partitioned Fuse tables.
  • Normalize distributed write input with TableWritePrepare, evaluate the partition expressions, and route equal partition values through GlobalShuffle before distributed INSERT SELECT writers.
  • Add a common node-local Fuse write layout before table.append_data(): evaluate partition expressions, full-sort by partition values, and rebuild blocks using the table's max_rows_per_block.
  • Reuse the existing Fuse partition splitter, block and segment serialization, statistics, compaction, and commit paths without introducing a new buffering or spill processor.

The goal is to reduce fragmented blocks when unordered input repeatedly crosses physical partition boundaries, while preserving the existing guarantee that a block or segment never spans physical partitions.

Current scope

  • Distributed INSERT SELECT uses GlobalShuffle to route equal evaluated partition values to the same writer node.
  • INSERT VALUES, streaming insert, COPY INTO TABLE, local INSERT SELECT, and other common append paths reuse the node-local full-sort write layout.
  • UPDATE, REPLACE, MERGE, and multi-table insert do not currently receive the new cross-node hash routing; they retain the existing partition-boundary guarantees.
  • Non-Fuse tables and Fuse tables without WRITE_DISTRIBUTION_MODE = 'hash' keep their existing write behavior.
  • bucket(count, value) controls persistent physical partition cardinality. It does not configure execution nodes or pipeline lanes.
  • Hash distribution reduces partition tails but does not guarantee exactly one block or segment per partition.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

AI assistance

  • AI usage: An AI coding agent assisted with implementation refactoring, CI diagnosis, and logic tests; the final changes were reviewed by the responsible human.
  • Responsible human: @KKould
  • The responsible human has read every line of this diff and can explain each change

This change is Reviewable

@github-actions github-actions Bot added the pr-feature this PR introduces a new feature to the codebase label Jul 28, 2026
@KKould
KKould force-pushed the feat/fuse-hash-write-distribution-v2 branch from 113b6c9 to 1f7e778 Compare July 30, 2026 07:13
@KKould KKould self-assigned this Jul 31, 2026
@KKould
KKould requested review from sundy-li and zhyass July 31, 2026 02:46
@KKould
KKould marked this pull request as ready for review July 31, 2026 02:46
@KKould

KKould commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f2eb9d4fd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/query/service/src/interpreters/interpreter_insert.rs
@KKould

KKould commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7789204554

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/query/service/src/pipelines/builders/builder_append_table.rs
Comment thread src/query/functions/src/scalars/hash.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants