zghong opened a new pull request, #66477:
URL: https://github.com/apache/doris/pull/66477

   ### What problem does this PR solve?
   
   Issue Number: close #66231
   
   Problem Summary:
   
   Hash Bucketing previously supported only the CRC32 hash function to map a 
row to its bucket. There was no way for users to choose a different bucketing 
scheme, which prevents scenarios (e.g. bucket pruning / colocation with 
external systems) that rely on a plain identity mapping of the bucket key, as 
shown in #66231.
   
   This PR introduces a table-level `distribution_hash_type` property for Hash 
Bucketing tables, supporting two values:
   
   - `crc32` (default, keeps existing behavior), means `crc32(key) % 
bucket_num`.
   - `identity` (map rows to buckets by the raw key value), means `key % 
bucket_num`.
   
   Main changes:
   
   - FE: parse and validate the new `distribution_hash_type` property in 
`PropertyAnalyzer`; carry the hash type through `HashDistributionInfo`, 
`HashDistributionDesc`, `ColocateGroupSchema`, `DataPartition`, 
`DistributionSpecHash` and related create-table / colocate paths; a new 
`FeMetaVersion` is added for metadata persistence. `ADD PARTITION` now inherits 
the table hash type.
   - Nereids: the optimizer is taught to recognize the non-CRC32 (identity) 
hash type when reasoning about distribution properties, so shuffle can be 
eliminated and bucket pruning (`HashDistributionPruner`, `PruneOlapScanTablet`) 
still works correctly for identity buckets.
   - BE: `TDistributionHashType` is added to thrift and threaded through the 
exchange / local-exchange sink operators and the tablet-sink partitioner so 
that the backend uses the same bucketing function as the FE plan, keeping FE/BE 
bucketing consistent. An identity partitioner is implemented.
   - thrift: add `TDistributionHashType` and propagate the field in 
`Descriptors`, `Partitions`, `PlanNodes` and `Types`.
   
   Before this PR: only CRC32 bucketing was available.
   
   After this PR: users can create Hash Bucketing tables with 
`"distribution_hash_type" = "identity"`, and FE plan optimization plus BE data 
sink produce consistent bucketing results. And more hash functions can be 
extended in the future.
   
   ### Release note
   
   Support a new table property `distribution_hash_type` for Hash Bucketing 
tables. It accepts `crc32` (default) and `identity` now, allowing users to 
choose the hash function used to map rows to buckets.
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. <!-- Explain the behavior change --> A new 
`distribution_hash_type` property is added; but default behavior (crc32) is 
unchanged.
   
   - Does this need documentation?
       - [ ] No.
       - [x] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 --> Detail docs will be added 
after further reviews.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to