Skip to content

[feature](bucket) Support custom distribution_hash_type for Hash Bucketing - #66477

Open
zghong wants to merge 33 commits into
apache:masterfrom
zghong:feat/distribution_hash_type
Open

zghong wants to merge 33 commits into
apache:masterfrom
zghong:feat/distribution_hash_type

Conversation

@zghong

@zghong zghong commented Aug 5, 2026

Copy link
Copy Markdown

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

    • Regression test
    • 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
  • Behavior changed:

    • No.
    • Yes. A new distribution_hash_type property is added; but default behavior (crc32) is unchanged.
  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@zghong

zghong commented Aug 5, 2026

Copy link
Copy Markdown
Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29153 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit f7cd8d5c88bfe2cd30ca929f66810365f0cb7f7d, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17594	3930	3917	3917
q2	2041	339	202	202
q3	10235	1474	809	809
q4	4685	475	338	338
q5	7625	859	575	575
q6	180	168	135	135
q7	755	785	613	613
q8	9384	1600	1659	1600
q9	5350	4130	4117	4117
q10	6759	1716	1350	1350
q11	524	351	319	319
q12	713	585	460	460
q13	18077	3286	2765	2765
q14	270	258	234	234
q15	q16	737	726	668	668
q17	1040	884	1016	884
q18	6632	5654	5544	5544
q19	1198	1321	1032	1032
q20	757	684	572	572
q21	5398	2865	2683	2683
q22	459	377	336	336
Total cold run time: 100413 ms
Total hot run time: 29153 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5010	4662	4623	4623
q2	290	326	219	219
q3	5048	5552	4617	4617
q4	2203	2289	1434	1434
q5	4540	4694	4391	4391
q6	231	177	126	126
q7	1866	1834	1516	1516
q8	2333	2052	2056	2052
q9	7218	6940	6717	6717
q10	4250	4196	3815	3815
q11	512	373	345	345
q12	704	713	503	503
q13	2952	3235	2767	2767
q14	279	294	254	254
q15	q16	659	686	592	592
q17	1290	1271	1246	1246
q18	12124	11050	11775	11050
q19	1120	1098	1092	1092
q20	2199	2193	1905	1905
q21	5292	4571	4625	4571
q22	533	456	396	396
Total cold run time: 60653 ms
Total hot run time: 54231 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 166066 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit f7cd8d5c88bfe2cd30ca929f66810365f0cb7f7d, data reload: false

query5	4329	600	463	463
query6	463	226	216	216
query7	4874	563	339	339
query8	318	160	149	149
query9	8797	3998	4011	3998
query10	505	395	311	311
query11	5895	2183	1981	1981
query12	159	101	97	97
query13	1272	586	417	417
query14	6052	4276	4012	4012
query14_1	3785	3804	3768	3768
query15	196	196	175	175
query16	982	461	435	435
query17	915	708	535	535
query18	2431	479	340	340
query19	209	186	147	147
query20	104	103	103	103
query21	229	153	139	139
query22	13014	12938	12857	12857
query23	15895	14945	14516	14516
query23_1	14666	14749	14752	14749
query24	7644	1707	1245	1245
query24_1	1227	1273	1258	1258
query25	562	470	389	389
query26	1325	349	217	217
query27	2593	595	392	392
query28	4578	1989	1968	1968
query29	1088	616	477	477
query30	350	261	225	225
query31	1189	1114	1072	1072
query32	115	66	63	63
query33	517	312	254	254
query34	1207	1110	626	626
query35	745	740	649	649
query36	768	770	707	707
query37	157	109	95	95
query38	1854	1763	1665	1665
query39	822	826	799	799
query39_1	788	794	793	793
query40	255	159	140	140
query41	66	65	62	62
query42	92	94	93	93
query43	318	321	278	278
query44	1444	742	750	742
query45	184	172	175	172
query46	1030	1183	707	707
query47	1534	1514	1444	1444
query48	418	434	312	312
query49	577	408	288	288
query50	1068	441	344	344
query51	10849	10369	10390	10369
query52	85	87	75	75
query53	257	279	211	211
query54	280	229	219	219
query55	75	74	67	67
query56	308	305	301	301
query57	1027	1001	929	929
query58	297	270	245	245
query59	1535	1624	1368	1368
query60	311	275	256	256
query61	152	184	151	151
query62	408	320	268	268
query63	241	198	214	198
query64	2867	1024	850	850
query65	3912	3836	3767	3767
query66	1824	472	364	364
query67	28523	28182	27342	27342
query68	3474	1603	968	968
query69	424	296	274	274
query70	862	809	743	743
query71	377	349	311	311
query72	3071	2679	2448	2448
query73	883	735	434	434
query74	4677	4485	4310	4310
query75	2383	2376	2022	2022
query76	2456	1158	786	786
query77	362	385	284	284
query78	11141	10971	10704	10704
query79	1366	1086	774	774
query80	778	564	516	516
query81	467	339	289	289
query82	618	185	139	139
query83	423	334	297	297
query84	329	170	138	138
query85	1116	614	518	518
query86	367	233	226	226
query87	1976	1936	1840	1840
query88	3764	2780	2796	2780
query89	398	327	278	278
query90	1839	209	200	200
query91	205	195	167	167
query92	63	59	58	58
query93	1545	1517	1051	1051
query94	621	371	311	311
query95	793	607	507	507
query96	1001	755	353	353
query97	2457	2466	2316	2316
query98	200	189	182	182
query99	742	728	615	615
Total cold run time: 253749 ms
Total hot run time: 166066 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.98 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit f7cd8d5c88bfe2cd30ca929f66810365f0cb7f7d, data reload: false

query1	0.01	0.01	0.01
query2	0.10	0.05	0.05
query3	0.26	0.14	0.14
query4	1.60	0.14	0.14
query5	0.24	0.22	0.23
query6	1.17	0.82	0.82
query7	0.05	0.01	0.01
query8	0.06	0.04	0.04
query9	0.40	0.31	0.32
query10	0.55	0.59	0.55
query11	0.20	0.14	0.14
query12	0.18	0.15	0.14
query13	0.47	0.46	0.48
query14	1.01	1.00	1.02
query15	0.60	0.59	0.59
query16	0.32	0.33	0.31
query17	1.14	1.12	1.11
query18	0.21	0.20	0.20
query19	2.06	1.97	1.93
query20	0.02	0.01	0.01
query21	15.44	0.21	0.14
query22	4.89	0.06	0.05
query23	16.11	0.31	0.12
query24	2.95	0.40	0.34
query25	0.10	0.07	0.05
query26	0.73	0.21	0.14
query27	0.03	0.03	0.05
query28	3.55	0.77	0.34
query29	12.51	4.01	3.17
query30	0.32	0.18	0.19
query31	2.77	0.55	0.32
query32	3.22	0.58	0.50
query33	3.27	3.23	3.16
query34	15.51	3.93	3.25
query35	3.25	3.25	3.19
query36	0.55	0.43	0.44
query37	0.10	0.07	0.07
query38	0.06	0.04	0.04
query39	0.05	0.03	0.03
query40	0.18	0.16	0.15
query41	0.09	0.04	0.03
query42	0.04	0.04	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.42 s
Total hot run time: 23.98 s

zghong added 7 commits August 31, 2026 01:21
…ash_type

# Conflicts:
#	be/src/exec/partitioner/partitioner.h
#	fe/fe-core/src/main/java/org/apache/doris/planner/HashDistributionPruner.java
#	fe/fe-core/src/test/java/org/apache/doris/planner/HashDistributionPrunerTest.java
Carry the effective storage hash type through FE-planned and BE-native local
bucket exchanges. Add fragment protocol metadata and execution-version gating
so older backends cannot silently execute IDENTITY layouts as CRC32.
@zghong

zghong commented Sep 2, 2026

Copy link
Copy Markdown
Author

run buildall

Restore compares table signatures using only intersecting partition names.
When the intersection is empty, an IDENTITY partition can be appended to a
CRC32 table, or vice versa. Subsequent writes use the table default hash
while tablet pruning uses the partition hash, so committed rows can be missed.
Include the non-CRC32 table default hash independently of the partition list.
Preserve legacy CRC32/random signatures and allow different bucket counts when
the hash algorithm matches. Reuse existing restore schema mismatch and force-replacement handling.

Reject restoring partitions into an existing table with an incompatible distribution hash algorithm, including when partition names do not overlap.
Problem Summary: Identity hash tests could pass without exercising the
intended distribution paths: mixed-hash joins could broadcast, set-operation
settings excluded storage bucket shuffle, and zero high bytes hid wide-value
truncation. Force and assert ordinary PARTITIONED joins, verify set-operation
basic-side properties and remote/local thrift hash fields, and use independent
arbitrary-precision high-byte, seed and NULL-tail vectors.

Also verify that the local-exchange selector creates the identity partitioner,
force multiple local channels, cover legacy-planner pruning, and assert the
exact SHOW CREATE hash property. Generate regression golden results through
the test runner and verify them with an independent result oracle.
Problem Summary: Older remote-Doris FEs ignore the new distribution
hash type in table metadata and prune identity buckets with CRC32.
A BIGINT value of 1 in an eight-bucket identity table is stored in
bucket 1, but a metadata-version-140 client selects bucket 7 and
misses the committed row. The same CRC32 table is read correctly.
Reject identity metadata exports to clients without version 141
support before copying table or partition metadata. Return an empty
required table_meta field so the error survives Thrift serialization.
Keep CRC32 and random-distribution exports unchanged.

Remote Doris clients with missing metadata versions or versions below
141 receive an explicit upgrade error when accessing identity tables,
instead of silently pruning the wrong tablets. CRC32 tables are
unaffected.
@zghong
zghong requested a review from luwei16 as a code owner September 18, 2026 06:31
…ash_type

# Conflicts:
#	be/src/agent/be_exec_version_manager.cpp
#	be/src/agent/be_exec_version_manager.h
#	fe/fe-common/src/main/java/org/apache/doris/common/Config.java
#	fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
#	fe/fe-core/src/test/java/org/apache/doris/planner/LocalShuffleNodeCoverageTest.java
Problem Summary: Keep static-analysis adaptations limited to the identity
hash implementation and its tests: equivalent scoped locking, uppercase
unsigned literals, test byte construction, and precise documented diagnostic
exceptions. Preserve test vectors and assertions. The unknown-wire enum
fixture's exception does not establish defined behavior for its invalid cast.
Unrelated clang-tidy tooling and core header changes are excluded.
@zghong
zghong force-pushed the feat/distribution_hash_type branch from 8c124d7 to 082b86b Compare September 18, 2026 09:36
@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 92.00% (115/125) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.53% (29566/46539)
Line Coverage 48.26% (307931/638124)
Region Coverage 43.88% (248558/566476)
Branch Coverage 45.42% (115533/254348)

@zghong

zghong commented Sep 18, 2026

Copy link
Copy Markdown
Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.54% (2064/2662)
Line Coverage 65.76% (37933/57686)
Region Coverage 53.15% (35514/66816)
Branch Coverage 56.53% (11414/20190)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 27394 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 082b86b9b247dca1b795cfae311acf8f09a1293a, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17532	3935	3878	3878
q2	2316	348	293	293
q3	9954	1389	798	798
q4	4680	485	347	347
q5	7516	826	548	548
q6	182	174	134	134
q7	730	800	590	590
q8	9388	1469	1506	1469
q9	5756	4182	4145	4145
q10	6801	1626	1341	1341
q11	435	270	243	243
q12	638	424	301	301
q13	18064	2607	1988	1988
q14	259	261	235	235
q15	q16	742	722	675	675
q17	1799	1046	1058	1046
q18	6604	5647	5550	5550
q19	1171	1260	1075	1075
q20	488	389	275	275
q21	5495	2546	2175	2175
q22	411	354	288	288
Total cold run time: 100961 ms
Total hot run time: 27394 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4157	4080	4059	4059
q2	740	571	581	571
q3	4550	4961	4311	4311
q4	2209	2303	1450	1450
q5	4209	4089	4097	4089
q6	219	178	124	124
q7	1676	1587	1429	1429
q8	2154	2244	2130	2130
q9	7494	7298	7269	7269
q10	4300	4269	3846	3846
q11	561	408	364	364
q12	726	746	511	511
q13	2412	2793	2137	2137
q14	306	324	276	276
q15	q16	691	709	670	670
q17	7923	7170	7059	7059
q18	11875	11115	11828	11115
q19	1233	1070	1097	1070
q20	2210	2206	1966	1966
q21	5781	4731	4653	4653
q22	531	454	387	387
Total cold run time: 65957 ms
Total hot run time: 59486 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 153651 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 082b86b9b247dca1b795cfae311acf8f09a1293a, data reload: false

query5	4317	607	453	453
query6	455	180	159	159
query7	4788	533	300	300
query8	322	173	172	172
query9	8768	3971	3974	3971
query10	468	305	236	236
query11	5829	2160	1977	1977
query12	148	98	94	94
query13	1257	552	391	391
query14	6484	4518	4222	4222
query14_1	4019	3966	3960	3960
query15	206	209	179	179
query16	978	487	372	372
query17	914	711	502	502
query18	2410	472	331	331
query19	190	169	134	134
query20	100	99	107	99
query21	218	130	114	114
query22	13085	12900	12751	12751
query23	15530	14573	14038	14038
query23_1	14162	14125	14036	14036
query24	7543	1736	1217	1217
query24_1	1263	1227	1225	1225
query25	518	396	329	329
query26	1272	329	155	155
query27	2694	533	342	342
query28	4490	1990	1971	1971
query29	1007	588	452	452
query30	311	233	197	197
query31	891	749	616	616
query32	139	89	84	84
query33	528	303	225	225
query34	1182	1073	653	653
query35	703	758	649	649
query36	804	837	706	706
query37	149	102	85	85
query38	1819	1758	1687	1687
query39	701	677	660	660
query39_1	642	669	622	622
query40	219	113	96	96
query41	71	101	61	61
query42	90	86	88	86
query43	337	342	293	293
query44	1344	681	695	681
query45	180	175	170	170
query46	1029	1181	706	706
query47	1481	1492	1377	1377
query48	385	417	296	296
query49	591	408	294	294
query50	1001	344	243	243
query51	10768	10484	10823	10484
query52	84	83	76	76
query53	234	261	175	175
query54	246	206	185	185
query55	76	72	65	65
query56	229	210	211	210
query57	1445	1401	1418	1401
query58	225	210	205	205
query59	1982	2054	1797	1797
query60	285	248	221	221
query61	148	138	141	138
query62	400	323	269	269
query63	213	177	174	174
query64	2783	1018	904	904
query65	4068	3918	3917	3917
query66	1800	423	319	319
query67	20221	20056	19870	19870
query68	3458	1493	910	910
query69	417	295	276	276
query70	942	894	869	869
query71	307	235	222	222
query72	3049	2688	2336	2336
query73	827	766	439	439
query74	4651	4507	4322	4322
query75	2316	2272	1949	1949
query76	2293	1088	726	726
query77	371	404	295	295
query78	9096	9295	8484	8484
query79	1295	1235	703	703
query80	589	443	346	346
query81	476	273	236	236
query82	636	161	121	121
query83	366	271	233	233
query84	310	144	113	113
query85	846	469	370	370
query86	336	240	222	222
query87	1991	1960	1833	1833
query88	3633	2730	2723	2723
query89	376	283	243	243
query90	1904	176	178	176
query91	169	163	124	124
query92	103	88	79	79
query93	1536	1397	860	860
query94	524	350	262	262
query95	661	439	337	337
query96	996	743	359	359
query97	2483	2430	2312	2312
query98	202	202	181	181
query99	742	711	609	609
Total cold run time: 241342 ms
Total hot run time: 153651 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.93 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 082b86b9b247dca1b795cfae311acf8f09a1293a, data reload: false

query1	0.01	0.00	0.00
query2	0.14	0.09	0.09
query3	0.37	0.24	0.24
query4	1.62	0.24	0.24
query5	0.32	0.31	0.31
query6	1.15	0.67	0.66
query7	0.04	0.00	0.01
query8	0.09	0.07	0.07
query9	0.48	0.38	0.38
query10	0.56	0.56	0.56
query11	0.33	0.18	0.19
query12	0.32	0.19	0.19
query13	0.52	0.52	0.52
query14	0.86	0.86	0.86
query15	0.67	0.59	0.57
query16	0.38	0.38	0.38
query17	0.99	0.98	0.98
query18	0.28	0.28	0.27
query19	1.88	1.74	1.77
query20	0.03	0.01	0.01
query21	15.39	0.37	0.30
query22	4.90	0.13	0.13
query23	15.87	0.48	0.30
query24	2.39	0.61	0.41
query25	0.15	0.10	0.10
query26	0.75	0.26	0.21
query27	0.11	0.10	0.09
query28	3.41	0.78	0.43
query29	12.47	4.15	3.24
query30	0.36	0.26	0.25
query31	2.76	0.58	0.35
query32	3.23	0.59	0.47
query33	2.97	2.95	2.98
query34	15.56	3.91	3.25
query35	3.16	3.13	3.13
query36	0.63	0.51	0.50
query37	0.12	0.09	0.09
query38	0.08	0.07	0.06
query39	0.07	0.06	0.06
query40	0.19	0.18	0.17
query41	0.13	0.08	0.08
query42	0.08	0.06	0.05
query43	0.07	0.07	0.06
Total cold run time: 95.89 s
Total hot run time: 24.93 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 97.58% (121/124) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.25% (34360/45062)
Line Coverage 61.16% (385840/630853)
Region Coverage 57.63% (325167/564201)
Branch Coverage 58.40% (148093/253568)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 77.97% (177/227) 🎉
Increment coverage report
Complete coverage report

@HappenLee

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot 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.

Static review of exact head 082b86b9b247dca1b795cfae311acf8f09a1293a. Requesting changes for two P1 correctness/lifecycle defects and one P2 resource-amplification issue.

Checkpoint conclusions:

  • Goal and scope: the PR broadly implements persisted IDENTITY bucket distribution across FE metadata/planning and BE routing, and the large cross-module change remains cohesive around that goal.
  • Data correctness and parallel paths: tablet routing, static pruning, load, remote exchange, both local-exchange planners, and the other supported canonical encodings agree. The remote legacy-DATE runtime-filter path does not, and can false-prune a matching bucket.
  • Concurrency and lifecycle: the cache mutex serializes cache builders, but it does not synchronize with merge(). Publishing a merger-owned wrapper to an ordinary local consumer can trip the merge invariant or race exact-set mutation against iteration. No separate lock-order or deadlock defect survived review.
  • Compatibility, configuration, and persistence: metadata version 141 and BE execution version 16 gates fail closed for IDENTITY, while absent fields preserve CRC32. CREATE/ADD/automatic partitioning, copies, replay, colocate validation, restore, and remote export otherwise retain or reject the new layout consistently; no new dynamic configuration surface was introduced.
  • Performance and memory: the per-bucket-count cache retains a value-count-sized vector and repeats hashing for every distinct selected bucket count, with no cache-level bound or eviction.
  • Tests: the changed unit/regression coverage is broad, but it does not cover remote DATE reconstruction, mixed local-merge/ordinary-local scheduling, or many selected bucket counts.
  • Error handling, observability, security, and writes: no additional error-contract, logging/metrics, authentication/authorization, outbound-network, transaction, or write-atomicity defect survived the full call-chain review.

The supplied focus file contained no additional focus. All 86 authoritative changed paths and all candidates were swept through two rounds; every convergence reviewer returned NO_NEW_VALUABLE_FINDINGS. This was a static review only: I did not run builds or tests, and treated PR/CI results as external evidence rather than independent validation.

it != _identity_bucket_prune_hashes.end()) {
return it->second;
}
_bucket_prune_hashes_started.store(true);

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.

[P1] Do not materialize this cache on a wrapper that can still be merged. With multiple producers and both local-merge and ordinary local targets, the first merge_from() stores the producer's shared wrapper in the unfinished merger, then publish() signals ordinary local consumers with that same wrapper. If pruning reaches this store before the next producer, merge() hits DORIS_CHECK(!_bucket_prune_hashes_started); if it overlaps just after that check, merge mutates _hybrid_set while this branch iterates it. Please delay exposure until the merger is complete or publish an independent immutable snapshot, and add a mixed-target scheduling test.

primitive_type, 0, bucket_num));
} else {
buckets->push_back(
RawValue::identity_hash(value, 0, primitive_type, 0, bucket_num));

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.

[P1] Normalize remote DATE values before IDENTITY bucket hashing. Exact filters serialize legacy DATE as a string, but _assign deserializes both DATE and DATETIME with DatelikeTargetType::DATE_TIME; this branch therefore hashes YYYY-MM-DD 00:00:00, while tablet routing hashes the stored DATE as YYYY-MM-DD. For 2026-01-02 with 3 buckets those encodings select buckets 2 and 1 respectively, so a remote filter can prune the bucket containing the match. Please parse TYPE_DATE as DATE (or normalize by primitive_type) and cover a serialized-filter round trip with a non-power-of-two bucket count.

if (_hybrid_set->contain_null()) {
buckets->push_back(RawValue::identity_hash(nullptr, 0, primitive_type, 0, bucket_num));
}
_identity_bucket_prune_hashes.emplace(bucket_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.

[P2] Bound the per-bucket-count IDENTITY cache. A scan may select partitions with different bucket counts, and each distinct count retained here stores one uint32_t per exact-set value. At the defaults, bucket counts 1..768 and a 40,960-value filter retain about 120 MiB and execute about 31 million hashes for this one runtime filter, with multiple filters multiplying both costs; the map has no cache-level bound or eviction. Please retain only the deduplicated selected buckets, compute per-count values transiently, or enforce a strict aggregate/LRU limit, and cover many distinct partition bucket counts.

Problem Summary: IDENTITY runtime-filter bucket pruning retained one
uint32_t per exact-set value for every selected partition bucket count.
A 40,960-value filter over counts 1 through 768 retained about 120 MiB of
vector elements even when many values selected the same buckets.

Cache only distinct bucket IDs using an allocator-aware temporary set,
construct a compact owning vector, and stop hashing once all buckets are
selected. Keep the existing mutex, cache sharing, hash semantics and CRC32
path unchanged. The stress test bounds retained vector capacity to 295,296
elements (about 1.13 MiB) for those counts, including a NULL value.

Reduce memory consumption of IDENTITY runtime-filter bucket pruning across
partitions with different bucket counts, without changing query results.
@zghong

zghong commented Sep 20, 2026

Copy link
Copy Markdown
Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28173 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 65bb8d307771203659e76f11d7421aac40b7da4b, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17605	4002	3936	3936
q2	2171	373	314	314
q3	9972	1434	809	809
q4	4687	474	349	349
q5	7490	841	549	549
q6	181	170	138	138
q7	774	792	606	606
q8	9376	1552	1580	1552
q9	5698	4170	4200	4170
q10	6837	1320	1031	1031
q11	427	270	240	240
q12	639	421	304	304
q13	18077	2620	1997	1997
q14	264	263	238	238
q15	q16	740	715	657	657
q17	1772	1132	965	965
q18	6465	5596	5580	5580
q19	1179	1238	1097	1097
q20	479	382	266	266
q21	5435	3354	3066	3066
q22	426	361	309	309
Total cold run time: 100694 ms
Total hot run time: 28173 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4509	4468	4383	4383
q2	717	551	527	527
q3	4790	5268	4578	4578
q4	2167	2350	1464	1464
q5	4696	4456	4501	4456
q6	243	182	135	135
q7	1837	1699	1552	1552
q8	2249	2073	2075	2073
q9	7369	6891	6874	6874
q10	3640	3555	3063	3063
q11	514	387	351	351
q12	706	696	499	499
q13	2294	2578	1993	1993
q14	260	268	247	247
q15	q16	656	690	599	599
q17	7291	6751	6698	6698
q18	11841	11066	11749	11066
q19	1092	1011	1023	1011
q20	2201	2176	1911	1911
q21	4994	4180	4372	4180
q22	516	458	409	409
Total cold run time: 64582 ms
Total hot run time: 58069 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 151734 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 65bb8d307771203659e76f11d7421aac40b7da4b, data reload: false

query5	4329	602	469	469
query6	430	208	187	187
query7	4799	525	290	290
query8	321	180	153	153
query9	8793	3969	3994	3969
query10	455	319	257	257
query11	5851	3550	3226	3226
query12	150	93	85	85
query13	1248	601	418	418
query14	6547	4518	4242	4242
query14_1	3946	3969	3866	3866
query15	200	191	172	172
query16	992	473	431	431
query17	868	653	519	519
query18	2433	429	326	326
query19	199	175	133	133
query20	79	77	80	77
query21	221	132	110	110
query22	12991	12892	12704	12704
query23	14025	13004	12510	12510
query23_1	12479	12395	12614	12395
query24	7302	1059	635	635
query24_1	677	696	678	678
query25	536	417	350	350
query26	1274	307	162	162
query27	2689	590	326	326
query28	4550	1968	1953	1953
query29	1594	720	527	527
query30	291	219	182	182
query31	902	761	639	639
query32	149	95	92	92
query33	536	322	257	257
query34	1211	1141	621	621
query35	727	755	653	653
query36	781	781	696	696
query37	145	106	89	89
query38	1824	1751	1718	1718
query39	690	676	662	662
query39_1	640	660	664	660
query40	224	132	120	120
query41	75	68	67	67
query42	96	97	87	87
query43	333	346	294	294
query44	1364	737	703	703
query45	182	178	161	161
query46	1100	1206	724	724
query47	1514	1536	1400	1400
query48	409	428	311	311
query49	584	402	299	299
query50	948	363	252	252
query51	10587	10367	10080	10080
query52	89	94	78	78
query53	237	254	190	190
query54	266	218	208	208
query55	79	75	71	71
query56	231	243	216	216
query57	1477	1449	1320	1320
query58	295	269	269	269
query59	1989	2071	1863	1863
query60	289	257	230	230
query61	169	165	163	163
query62	402	319	269	269
query63	212	176	179	176
query64	2930	1033	825	825
query65	3438	3380	3398	3380
query66	1783	414	297	297
query67	20176	20028	19791	19791
query68	3098	1444	893	893
query69	397	311	256	256
query70	877	798	793	793
query71	292	230	214	214
query72	2614	2543	2241	2241
query73	816	818	425	425
query74	4603	4459	4339	4339
query75	2307	2272	1927	1927
query76	2269	1114	746	746
query77	352	403	296	296
query78	9078	8958	8465	8465
query79	1395	1090	736	736
query80	712	463	369	369
query81	541	319	277	277
query82	595	152	120	120
query83	291	221	192	192
query84	312	147	114	114
query85	881	464	382	382
query86	379	248	232	232
query87	2018	1952	1836	1836
query88	3624	2743	2711	2711
query89	368	284	240	240
query90	1821	179	175	175
query91	165	161	124	124
query92	102	91	84	84
query93	1447	1416	876	876
query94	597	350	304	304
query95	636	445	333	333
query96	1086	803	354	354
query97	2470	2446	2329	2329
query98	160	148	143	143
query99	723	732	611	611
Total cold run time: 236046 ms
Total hot run time: 151734 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.97 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 65bb8d307771203659e76f11d7421aac40b7da4b, data reload: false

query1	0.01	0.01	0.00
query2	0.14	0.09	0.08
query3	0.36	0.24	0.25
query4	1.61	0.23	0.25
query5	0.32	0.30	0.32
query6	1.16	0.66	0.66
query7	0.05	0.01	0.00
query8	0.08	0.08	0.07
query9	0.50	0.39	0.39
query10	0.57	0.57	0.57
query11	0.32	0.19	0.18
query12	0.32	0.19	0.19
query13	0.52	0.52	0.52
query14	0.88	0.86	0.86
query15	0.67	0.59	0.59
query16	0.38	0.39	0.38
query17	1.01	0.99	0.99
query18	0.31	0.29	0.29
query19	1.95	1.79	1.76
query20	0.03	0.01	0.02
query21	15.41	0.35	0.31
query22	4.91	0.14	0.13
query23	15.85	0.49	0.29
query24	2.42	0.61	0.43
query25	0.15	0.10	0.10
query26	0.74	0.27	0.21
query27	0.10	0.10	0.10
query28	3.35	0.80	0.44
query29	12.45	4.18	3.26
query30	0.37	0.27	0.25
query31	2.77	0.59	0.34
query32	3.24	0.59	0.48
query33	2.88	2.96	2.88
query34	15.61	3.93	3.25
query35	3.18	3.15	3.16
query36	0.63	0.53	0.49
query37	0.12	0.09	0.09
query38	0.09	0.06	0.06
query39	0.07	0.06	0.06
query40	0.20	0.16	0.15
query41	0.12	0.07	0.07
query42	0.08	0.07	0.06
query43	0.08	0.06	0.07
Total cold run time: 96.01 s
Total hot run time: 24.97 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 77.97% (177/227) 🎉
Increment coverage report
Complete coverage report

Problem Summary: The latest upstream DATE round-trip test still calls the
CRC32-only one-argument bucket-prune hash API. After merging master into
the IDENTITY branch, that call fails to compile because the API requires
an explicit hash algorithm and bucket count.

Adapt the actual test caller instead of adding a compatibility overload or
default arguments. Preserve its raw CRC32 assertion and also verify
IDENTITY buckets against the original DATE for bucket counts 3, 7 and 97.
Production hashing and its three-argument interface remain unchanged.
@zghong

zghong commented Sep 21, 2026

Copy link
Copy Markdown
Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28144 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit caf27b17215c2ebe62b7c48f2c4e2423da293fe7, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17019	3909	3906	3906
q2	2201	380	309	309
q3	9942	1429	792	792
q4	4668	480	350	350
q5	7556	834	551	551
q6	190	172	137	137
q7	769	782	605	605
q8	9463	1536	1555	1536
q9	5535	4242	4181	4181
q10	6822	1320	994	994
q11	439	272	251	251
q12	633	424	301	301
q13	18037	2663	2010	2010
q14	262	255	234	234
q15	q16	738	719	665	665
q17	1799	1079	1037	1037
q18	6514	6200	5614	5614
q19	1193	1169	1053	1053
q20	477	397	262	262
q21	5580	3404	3043	3043
q22	461	371	313	313
Total cold run time: 100298 ms
Total hot run time: 28144 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4647	4738	4418	4418
q2	729	572	532	532
q3	4804	5143	4563	4563
q4	2194	2336	1469	1469
q5	4575	4392	4643	4392
q6	226	175	130	130
q7	1797	1731	1525	1525
q8	2342	2096	2029	2029
q9	7353	7326	7224	7224
q10	3655	3612	3086	3086
q11	524	378	343	343
q12	707	707	509	509
q13	2285	2602	1997	1997
q14	314	278	252	252
q15	q16	662	678	603	603
q17	7315	6705	6655	6655
q18	11892	11011	11810	11011
q19	1083	1027	996	996
q20	2196	2190	1911	1911
q21	5037	4090	4310	4090
q22	509	477	407	407
Total cold run time: 64846 ms
Total hot run time: 58142 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 152234 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit caf27b17215c2ebe62b7c48f2c4e2423da293fe7, data reload: false

query5	4307	602	466	466
query6	421	212	192	192
query7	4805	552	301	301
query8	324	175	165	165
query9	8786	4030	4012	4012
query10	461	325	256	256
query11	5911	3560	3239	3239
query12	143	92	82	82
query13	1233	611	393	393
query14	6493	4500	4258	4258
query14_1	3945	3903	3993	3903
query15	200	198	180	180
query16	984	444	434	434
query17	915	672	557	557
query18	2434	457	335	335
query19	205	182	147	147
query20	84	83	80	80
query21	221	139	116	116
query22	13123	13074	12807	12807
query23	14063	12880	12440	12440
query23_1	12415	12591	12594	12591
query24	7210	1203	678	678
query24_1	712	694	787	694
query25	574	428	371	371
query26	1297	335	167	167
query27	2645	561	332	332
query28	4539	1993	1959	1959
query29	1615	725	497	497
query30	300	222	182	182
query31	888	747	635	635
query32	152	90	88	88
query33	524	295	238	238
query34	1196	1104	635	635
query35	721	750	630	630
query36	806	799	716	716
query37	149	107	94	94
query38	1837	1760	1680	1680
query39	693	694	663	663
query39_1	654	643	643	643
query40	225	123	99	99
query41	66	63	62	62
query42	95	93	92	92
query43	335	347	301	301
query44	1393	702	692	692
query45	178	182	176	176
query46	1060	1180	707	707
query47	1487	1535	1405	1405
query48	403	393	271	271
query49	598	402	289	289
query50	1012	346	250	250
query51	10470	10335	10364	10335
query52	87	87	75	75
query53	247	269	184	184
query54	247	196	184	184
query55	77	73	68	68
query56	239	224	221	221
query57	1447	1414	1345	1345
query58	286	254	258	254
query59	1987	2039	1858	1858
query60	286	222	243	222
query61	145	143	147	143
query62	407	315	263	263
query63	211	178	179	178
query64	2827	990	803	803
query65	3478	3406	3428	3406
query66	1831	422	304	304
query67	20169	19926	19794	19794
query68	3336	1539	955	955
query69	430	340	265	265
query70	904	840	816	816
query71	299	245	214	214
query72	2672	2459	2233	2233
query73	825	834	429	429
query74	4655	4461	4278	4278
query75	2386	2326	1930	1930
query76	2307	1118	740	740
query77	367	404	297	297
query78	9009	8991	8434	8434
query79	1207	1161	744	744
query80	502	470	358	358
query81	530	328	283	283
query82	266	162	124	124
query83	217	224	191	191
query84	292	143	112	112
query85	793	452	378	378
query86	288	236	228	228
query87	1989	1987	1836	1836
query88	3653	2751	2705	2705
query89	329	292	247	247
query90	2080	185	174	174
query91	169	186	126	126
query92	103	92	93	92
query93	1449	1457	832	832
query94	508	320	302	302
query95	661	441	329	329
query96	1014	755	346	346
query97	2402	2426	2320	2320
query98	162	159	166	159
query99	713	732	607	607
Total cold run time: 235384 ms
Total hot run time: 152234 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.01 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit caf27b17215c2ebe62b7c48f2c4e2423da293fe7, data reload: false

query1	0.01	0.01	0.00
query2	0.09	0.05	0.05
query3	0.26	0.14	0.12
query4	1.61	0.14	0.13
query5	0.24	0.22	0.22
query6	1.15	0.93	0.92
query7	0.04	0.01	0.00
query8	0.05	0.04	0.03
query9	0.39	0.32	0.34
query10	0.59	0.56	0.57
query11	0.20	0.14	0.14
query12	0.18	0.15	0.15
query13	0.46	0.47	0.48
query14	0.95	0.95	0.94
query15	0.60	0.60	0.57
query16	0.31	0.33	0.32
query17	1.11	1.04	1.10
query18	0.20	0.20	0.20
query19	2.04	1.92	1.94
query20	0.02	0.01	0.01
query21	15.47	0.21	0.14
query22	4.89	0.06	0.05
query23	16.12	0.31	0.12
query24	2.98	0.42	0.32
query25	0.11	0.05	0.05
query26	0.75	0.22	0.16
query27	0.04	0.04	0.03
query28	3.49	0.84	0.36
query29	12.51	4.07	3.23
query30	0.27	0.16	0.15
query31	2.77	0.55	0.32
query32	3.21	0.58	0.51
query33	3.20	3.22	3.15
query34	15.49	3.90	3.27
query35	3.22	3.22	3.24
query36	0.57	0.43	0.42
query37	0.10	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.24	0.22	0.17
query41	0.09	0.03	0.04
query42	0.05	0.04	0.03
query43	0.05	0.05	0.04
Total cold run time: 96.21 s
Total hot run time: 24.01 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 97.58% (121/124) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.28% (34367/45052)
Line Coverage 61.24% (386248/630692)
Region Coverage 57.76% (325898/564264)
Branch Coverage 58.48% (148270/253529)

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.

[Bug] Data skew in Hash Bucketing with CRC32

3 participants