Skip to content

[fix](be) Fix missing decimal precision and scale for legacy decimal data#65419

Open
jacktengg wants to merge 1 commit into
apache:masterfrom
jacktengg:wt-fix-dec-precision
Open

[fix](be) Fix missing decimal precision and scale for legacy decimal data#65419
jacktengg wants to merge 1 commit into
apache:masterfrom
jacktengg:wt-fix-dec-precision

Conversation

@jacktengg

@jacktengg jacktengg commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #26572, #63569

Problem Summary:

Segments written before decimal ColumnMetaPB precision and scale were persisted can miss precision and scale for decimal types in metadata . Regular columns, complex decimal children may then build decimal DataType instances without the logical precision/scale from TabletSchema, and result in error "Wrong precision 0, min: 1, max: 76". This change centralizes decimal metadata recovery from TabletSchema, applies it before ColumnReader/DataType creation.

Release note

Fix reading legacy decimal whose segment metadata is missing decimal precision and scale.

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?

@jacktengg

Copy link
Copy Markdown
Contributor Author

/review

@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at 11:47 AM.
Workflow run: https://github.com/apache/doris/actions/runs/29009677710

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.


namespace {

void fill_missing_decimal_precision(ColumnMetaPB* meta, const TabletColumn& column) {

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.

一把把输入参数放第一个,返回值放后面

// Segments written before #26572 do not persist decimal precision/frac in
// ColumnMetaPB, so recover the logical p/s from TabletSchema before
// ColumnReader builds DataTypeDecimal.
fill_missing_decimal_precision_from_schema(&meta, _tablet_schema);

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.

如果你再这里修改了,那么上次的fix 还有用没?
另外,这里好像没区分decimalv2还是decimal v3? 比如如果是decimal v2 怎么办?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

上次的fix可以不用了。

}
}
} else if (is_numeric_type(type)) {
} else if (field_is_numeric_type(type)) {

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.

这个变动的原因是?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

删除重复代码is_numeric_type。

@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

// Segments written before #26572 do not persist decimal precision/frac in
// ColumnMetaPB, so recover the logical p/s from TabletSchema before
// ColumnReader builds DataTypeDecimal.
fill_missing_decimal_precision_from_schema(&meta, _tablet_schema);

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.

在Segment::_parse_footer 的时候把里面的ColumnMetaPB 改了就行。

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 90.24% (37/41) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.79% (29973/40074)
Line Coverage 58.86% (328741/558545)
Region Coverage 55.64% (275889/495813)
Branch Coverage 56.90% (121394/213350)

…data

Related PR: apache#26572, apache#63569

Problem Summary:
Segments written before decimal ColumnMetaPB precision and scale were persisted can miss decimal precision and scale in metadata. Regular columns, complex decimal children may then build decimal DataType instances without the logical precision/scale from TabletSchema. This change centralizes decimal metadata recovery from TabletSchema, applies it before ColumnReader/DataType creation.

Fix legacy segment footer parsing to recover missing decimal precision and scale before column readers and data types are created.
@jacktengg jacktengg force-pushed the wt-fix-dec-precision branch from 262cfa2 to 4283283 Compare July 9, 2026 15:18
@jacktengg jacktengg changed the title [fix](be) Fix reading legacy decimal whose segment metadata is missing decimal precision or scale [fix](be) Fix missing decimal precision and scale for legacy decimal data Jul 9, 2026
@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17667	4094	4078	4078
q2	2061	327	204	204
q3	10220	1497	866	866
q4	4683	466	335	335
q5	7544	838	579	579
q6	180	167	135	135
q7	789	828	632	632
q8	9358	1614	1714	1614
q9	5709	4425	4414	4414
q10	6782	1784	1522	1522
q11	503	351	310	310
q12	702	550	434	434
q13	18116	3436	2796	2796
q14	269	266	240	240
q15	q16	791	774	710	710
q17	999	1047	933	933
q18	7096	5955	5555	5555
q19	1307	1390	1067	1067
q20	781	627	580	580
q21	6390	2821	2664	2664
q22	465	376	308	308
Total cold run time: 102412 ms
Total hot run time: 29976 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5214	4893	4844	4844
q2	290	342	219	219
q3	5064	5306	4688	4688
q4	2109	2164	1357	1357
q5	4862	4996	4770	4770
q6	237	180	126	126
q7	1872	1847	1572	1572
q8	2517	2148	2104	2104
q9	7765	7365	7254	7254
q10	4656	4621	4171	4171
q11	528	388	351	351
q12	726	739	531	531
q13	2973	3355	2778	2778
q14	289	291	258	258
q15	q16	679	690	616	616
q17	1291	1284	1276	1276
q18	7472	6893	6851	6851
q19	1070	1077	1045	1045
q20	2227	2212	1951	1951
q21	5420	4646	4435	4435
q22	525	455	406	406
Total cold run time: 57786 ms
Total hot run time: 51603 ms

@hello-stephen

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

query5	4392	640	474	474
query6	484	240	212	212
query7	4855	636	366	366
query8	361	195	180	180
query9	8820	4066	4059	4059
query10	464	334	324	324
query11	5902	2357	2197	2197
query12	172	105	108	105
query13	1261	613	419	419
query14	7059	5331	4934	4934
query14_1	4298	4286	4264	4264
query15	230	205	185	185
query16	1030	483	476	476
query17	1289	783	594	594
query18	2768	472	362	362
query19	315	197	157	157
query20	114	113	109	109
query21	240	164	135	135
query22	13615	13699	13419	13419
query23	17478	16450	16062	16062
query23_1	16367	16318	16241	16241
query24	7478	1744	1299	1299
query24_1	1339	1283	1312	1283
query25	574	481	411	411
query26	1301	365	211	211
query27	2446	607	393	393
query28	4322	2031	2017	2017
query29	1093	641	506	506
query30	335	266	231	231
query31	1132	1111	981	981
query32	112	64	62	62
query33	530	337	260	260
query34	1152	1147	659	659
query35	768	795	673	673
query36	1419	1372	1262	1262
query37	209	113	89	89
query38	1882	1698	1638	1638
query39	919	923	868	868
query39_1	885	874	893	874
query40	246	163	139	139
query41	66	65	62	62
query42	94	93	93	93
query43	317	325	280	280
query44	1405	780	755	755
query45	197	189	179	179
query46	1120	1195	788	788
query47	2332	2321	2184	2184
query48	412	414	299	299
query49	575	423	310	310
query50	1024	435	329	329
query51	10626	10545	10838	10545
query52	86	88	75	75
query53	264	287	194	194
query54	296	241	221	221
query55	76	73	65	65
query56	307	281	296	281
query57	1428	1382	1331	1331
query58	280	261	256	256
query59	1603	1644	1437	1437
query60	302	267	263	263
query61	160	156	154	154
query62	700	647	560	560
query63	245	205	199	199
query64	2770	1076	885	885
query65	4839	4776	4785	4776
query66	1799	532	385	385
query67	29546	29595	29330	29330
query68	3172	1531	1065	1065
query69	453	317	278	278
query70	1055	962	992	962
query71	338	341	311	311
query72	3164	2727	2474	2474
query73	822	738	434	434
query74	5084	4964	4809	4809
query75	2619	2600	2230	2230
query76	2325	1179	786	786
query77	364	388	286	286
query78	12328	12310	11782	11782
query79	1423	1129	777	777
query80	1321	536	443	443
query81	508	335	284	284
query82	566	159	132	132
query83	393	319	289	289
query84	281	165	131	131
query85	975	600	505	505
query86	435	295	303	295
query87	1818	1829	1751	1751
query88	3750	2821	2801	2801
query89	455	404	354	354
query90	1953	205	193	193
query91	200	187	163	163
query92	63	61	55	55
query93	1522	1526	973	973
query94	835	361	313	313
query95	775	582	486	486
query96	1052	826	366	366
query97	2708	2671	2545	2545
query98	216	205	205	205
query99	1160	1172	1019	1019
Total cold run time: 267003 ms
Total hot run time: 180810 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.10	0.04	0.04
query3	0.25	0.12	0.12
query4	1.63	0.14	0.13
query5	0.25	0.21	0.22
query6	1.24	1.05	1.10
query7	0.04	0.01	0.01
query8	0.06	0.03	0.03
query9	0.37	0.30	0.32
query10	0.56	0.55	0.54
query11	0.19	0.14	0.14
query12	0.18	0.15	0.14
query13	0.47	0.49	0.48
query14	1.01	1.00	1.02
query15	0.63	0.62	0.59
query16	0.31	0.33	0.31
query17	1.14	1.12	1.08
query18	0.22	0.20	0.22
query19	2.04	1.92	1.99
query20	0.02	0.01	0.02
query21	15.55	0.23	0.14
query22	4.86	0.06	0.05
query23	16.13	0.32	0.12
query24	2.97	0.40	0.31
query25	0.12	0.05	0.03
query26	0.72	0.20	0.15
query27	0.04	0.03	0.04
query28	3.50	0.88	0.54
query29	12.48	4.13	3.34
query30	0.31	0.14	0.15
query31	2.76	0.61	0.31
query32	3.22	0.60	0.48
query33	3.13	3.18	3.19
query34	15.71	4.22	3.51
query35	3.55	3.54	3.51
query36	0.56	0.43	0.41
query37	0.11	0.07	0.06
query38	0.04	0.04	0.03
query39	0.04	0.02	0.02
query40	0.19	0.16	0.14
query41	0.10	0.04	0.03
query42	0.04	0.03	0.02
query43	0.05	0.03	0.03
Total cold run time: 96.9 s
Total hot run time: 24.88 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants