Skip to content

[bug](analytic) fix partition by column when it overflow haven't convert to column64#65240

Open
zhangstar333 wants to merge 1 commit into
apache:masterfrom
zhangstar333:column_overflow
Open

[bug](analytic) fix partition by column when it overflow haven't convert to column64#65240
zhangstar333 wants to merge 1 commit into
apache:masterfrom
zhangstar333:column_overflow

Conversation

@zhangstar333

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

when insert into partition by column, will be call insert_range_from_ignore_overflow function,
the dst column maybe overflow, so need add the convert_column_if_overflow function to convert to column64。

Problem Summary:

Release note

None

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.
  • Does this need documentation?

    • No.
    • Yes.

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?

@zhangstar333 zhangstar333 changed the title update [bug](analytic) fix partition by column when it overflow haven't convert to column64 Jul 6, 2026
@zhangstar333

Copy link
Copy Markdown
Contributor Author

/review

@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@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.

Automated review result: requesting changes for one correctness gap.

The PR fixes the demonstrated count() over(partition by str) overflow path for partition/order comparison buffers, and the changed expected output is deterministic. However, the same analytic buffering code still leaves aggregate argument columns unconverted, so string-valued window aggregates can still read corrupt ColumnString offsets after the buffered argument data exceeds 4GB.

Critical checkpoint conclusions:

  • Goal/test: the stated partition-key overflow case is covered, but the broader analytic string-buffer goal is incomplete for aggregate arguments.
  • Scope: the change is small and focused, but it misses a parallel buffer path in the same function.
  • Concurrency/lifecycle/config/compatibility: no new concurrency, lifecycle, configuration, persistence, or protocol compatibility concerns found.
  • Parallel paths: _agg_input_columns is the missing parallel path; it appends through the same overflow-ignoring helper and is later consumed by window aggregate functions.
  • Tests: the regression output for count() over(partition by str) is correct, and the unit test covers String32 to String64 append. Missing coverage remains for large string-valued window aggregate arguments such as max(str) or first_value(str).
  • Performance/observability/data writes: no separate issue found beyond the correctness gap above.

Subagent conclusions:

  • OPT-001 was accepted as the inline comment.
  • TESTCFG-001 was merged as a duplicate of OPT-001; it confirmed the expected output math and the test gap.
  • Convergence round 1 ended with both optimizer-rewrite and tests-session-config reporting NO_NEW_VALUABLE_FINDINGS.

No additional user-provided review focus was supplied.

Validation was static only: this shallow runner lacks the base revision locally, .worktree_initialized, and thirdparty/installed, so BE tests/builds were not run. The GitHub PR patch and PR-scoped API data were used as the authoritative review inputs.

@@ -791,6 +797,7 @@ Status AnalyticSinkOperatorX::_add_input_block(doris::RuntimeState* state, Block
RETURN_IF_ERROR(
_insert_range_column(input_block, local_state._partition_by_eq_expr_ctxs[i],
local_state._partition_by_columns[i].get(), block_rows));

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.

This conversion only covers the partition/order comparison buffers. The aggregate argument buffers above still append through _insert_range_column() into _agg_input_columns, which also uses insert_range_from_ignore_overflow(), but those columns are later handed unchanged to add_range_single_place(). A large string-valued window aggregate such as max(str) over(partition by u_city) or first_value(str) ... can therefore still accumulate a ColumnString argument buffer past 4GB and read wrapped offsets; string min/max currently reads with SingleValueDataString via ColumnString::get_data_at(), and first/last/lead/lag keep row references into the same buffered columns. Please apply the overflow conversion to the aggregate argument buffers as well, and make sure the affected string window aggregate readers handle a promoted ColumnString64 input.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17747	4078	4051	4051
q2	1992	315	199	199
q3	10357	1432	834	834
q4	4688	467	337	337
q5	7528	866	578	578
q6	203	169	139	139
q7	792	851	621	621
q8	10090	1609	1683	1609
q9	5946	4427	4389	4389
q10	6801	1804	1496	1496
q11	501	344	310	310
q12	729	556	470	470
q13	18074	3307	2741	2741
q14	272	263	249	249
q15	q16	803	773	712	712
q17	1418	1085	806	806
q18	6788	5623	5577	5577
q19	1529	1273	1110	1110
q20	745	632	560	560
q21	5833	2668	2520	2520
q22	421	354	302	302
Total cold run time: 103257 ms
Total hot run time: 29610 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4360	4330	4274	4274
q2	295	318	205	205
q3	4564	4960	4415	4415
q4	2051	2142	1354	1354
q5	4401	4289	4305	4289
q6	231	176	129	129
q7	1751	2040	1692	1692
q8	2510	2171	2171	2171
q9	7757	7697	7934	7697
q10	4768	4719	4226	4226
q11	562	427	488	427
q12	736	739	546	546
q13	3311	3506	3022	3022
q14	309	313	261	261
q15	q16	759	749	641	641
q17	1346	1321	1312	1312
q18	7988	7268	6817	6817
q19	1127	1084	1086	1084
q20	2202	2200	1934	1934
q21	5249	4610	4421	4421
q22	520	473	393	393
Total cold run time: 56797 ms
Total hot run time: 51310 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 173257 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 b7a3060796b8fb86dbbd720d7065f3ac558180aa, data reload: false

query5	4321	643	503	503
query6	466	245	196	196
query7	4858	590	352	352
query8	330	186	172	172
query9	8724	4116	4116	4116
query10	475	363	297	297
query11	5857	2359	2150	2150
query12	162	110	107	107
query13	1266	611	464	464
query14	6280	5299	4972	4972
query14_1	4302	4278	4330	4278
query15	220	203	184	184
query16	990	488	475	475
query17	1128	718	588	588
query18	2435	486	348	348
query19	216	189	157	157
query20	144	107	105	105
query21	228	155	130	130
query22	13638	13707	13402	13402
query23	17387	16440	16086	16086
query23_1	16235	16189	16313	16189
query24	7469	1772	1312	1312
query24_1	1314	1316	1285	1285
query25	552	443	355	355
query26	1345	357	201	201
query27	2585	600	365	365
query28	4467	2056	2081	2056
query29	1040	591	473	473
query30	333	260	231	231
query31	1115	1084	971	971
query32	100	65	58	58
query33	511	323	270	270
query34	1178	1147	651	651
query35	762	788	651	651
query36	1407	1429	1218	1218
query37	153	104	88	88
query38	1876	1659	1626	1626
query39	919	910	889	889
query39_1	868	896	894	894
query40	243	159	141	141
query41	66	62	63	62
query42	99	92	93	92
query43	320	326	285	285
query44	1519	825	790	790
query45	197	192	177	177
query46	1070	1274	745	745
query47	2428	2304	2295	2295
query48	413	420	317	317
query49	571	436	315	315
query50	1097	431	339	339
query51	4407	4474	4321	4321
query52	85	85	75	75
query53	269	276	205	205
query54	289	226	211	211
query55	73	73	72	72
query56	305	315	291	291
query57	1426	1409	1303	1303
query58	289	269	271	269
query59	1529	1605	1464	1464
query60	290	268	252	252
query61	153	146	143	143
query62	705	643	546	546
query63	239	203	209	203
query64	2518	768	618	618
query65	4911	4783	4787	4783
query66	1815	499	381	381
query67	29401	29431	29335	29335
query68	3091	1651	1023	1023
query69	407	290	261	261
query70	1075	985	952	952
query71	347	320	310	310
query72	2878	2575	2300	2300
query73	873	794	445	445
query74	5133	4925	4762	4762
query75	2615	2565	2216	2216
query76	2330	1190	816	816
query77	361	378	286	286
query78	12331	12449	11767	11767
query79	1240	1101	739	739
query80	589	542	450	450
query81	460	318	280	280
query82	232	153	119	119
query83	306	318	293	293
query84	280	155	127	127
query85	898	594	518	518
query86	323	299	286	286
query87	1831	1813	1722	1722
query88	3771	2830	2834	2830
query89	439	407	361	361
query90	2179	196	195	195
query91	196	189	163	163
query92	63	59	58	58
query93	1538	1555	960	960
query94	549	354	323	323
query95	806	596	495	495
query96	1070	813	383	383
query97	2674	2670	2546	2546
query98	229	202	199	199
query99	1195	1138	1026	1026
Total cold run time: 257127 ms
Total hot run time: 173257 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.25	0.14	0.13
query4	1.60	0.13	0.13
query5	0.23	0.21	0.22
query6	1.26	1.08	1.06
query7	0.03	0.01	0.00
query8	0.05	0.04	0.04
query9	0.36	0.30	0.31
query10	0.55	0.57	0.55
query11	0.19	0.13	0.14
query12	0.18	0.15	0.15
query13	0.47	0.46	0.48
query14	1.01	1.00	1.00
query15	0.61	0.61	0.60
query16	0.29	0.33	0.33
query17	1.10	1.10	1.08
query18	0.21	0.21	0.20
query19	2.04	1.96	1.95
query20	0.01	0.01	0.02
query21	15.43	0.20	0.13
query22	4.99	0.06	0.05
query23	16.13	0.32	0.12
query24	3.00	0.43	0.32
query25	0.11	0.06	0.03
query26	0.73	0.21	0.16
query27	0.05	0.04	0.04
query28	3.53	0.90	0.54
query29	12.60	4.31	3.46
query30	0.27	0.15	0.14
query31	2.77	0.58	0.31
query32	3.22	0.61	0.49
query33	3.16	3.30	3.21
query34	15.49	4.21	3.54
query35	3.53	3.52	3.55
query36	0.55	0.43	0.44
query37	0.09	0.07	0.07
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.18	0.16	0.16
query41	0.08	0.03	0.03
query42	0.03	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.61 s
Total hot run time: 25.26 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 94.59% (35/37) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.71% (29780/39859)
Line Coverage 58.71% (326362/555927)
Region Coverage 55.51% (273792/493270)
Branch Coverage 56.80% (120640/212403)

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.

2 participants