Skip to content

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #48964

… nested decimal precision (#48964)

before this pr , we deduce the precision of the function named_struct
containing the decimal type is same with the precision of the decimal
type in select . In this case we can not make right named_struct for
multiple decimal value
like :
```
mysql> create table t01 (a decimal(6,3), d struct<col:bigint, col1:decimal(7,2)>) properties ("replication_num"="1");
Query OK, 0 rows affected (0.14 sec)

mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 345.24));
Query OK, 1 row affected (0.26 sec)
{'label':'label_a2dc895ee7834701_841639ad6d93923f', 'status':'VISIBLE', 'txnId':'9010'}

mysql> select named_struct("col_11", a, "col_12", d) from t01;
+--------------------------------------------------------+
| named_struct("col_11", a, "col_12", d)                 |
+--------------------------------------------------------+
| {"col_11":123.321, "col_12":{"col":1, "col1":345.240}} |
+--------------------------------------------------------+
1 row in set (0.17 sec)

mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 12345.24));
Query OK, 1 row affected (0.17 sec)
{'label':'label_77ed6047f6a6494d_810c26becfd0535c', 'status':'VISIBLE', 'txnId':'9011'}
mysql> select named_struct("col_11", a, "col_12", d) from t01;
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.6)[E-255]Arithmetic overflow when converting value 12345.24 from type Decimal(7, 2) to type Decimal(6, 3)
mysql> desc verbose select named_struct("col_11", a, "col_12", d) from t01;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Explain String(Nereids Planner)                                                                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                                                                                                                                              |
|   OUTPUT EXPRS:                                                                                                                                                                              |
|     named_struct("col_11", a, "col_12", d)[#2]                                                                                                                                               |
|   PARTITION: RANDOM                                                                                                                                                                          |
|                                                                                                                                                                                              |
|   HAS_COLO_PLAN_NODE: false                                                                                                                                                                  |
|                                                                                                                                                                                              |
|   VRESULT SINK                                                                                                                                                                               |
|      MYSQL_PROTOCAL                                                                                                                                                                          |
|                                                                                                                                                                                              |
|   0:VOlapScanNode(50)                                                                                                                                                                        |
|      TABLE: tt.t01(t01), PREAGGREGATION: ON                                                                                                                                                  |
|      partitions=1/1 (t01)                                                                                                                                                                    |
|      tablets=10/10, tabletList=1741751856342,1741751856344,1741751856346 ...                                                                                                                 |
|      cardinality=2, avgRowSize=2955.0, numNodes=1                                                                                                                                            |
|      pushAggOp=NONE                                                                                                                                                                          |
|      final projections: named_struct('col_11', a[#0], 'col_12', CAST(d[#1] AS struct<col:bigint,col1:decimalv3(6,3)>))                                                                       |
|      final project output tuple id: 1                                                                                                                                                        |
|      tuple ids: 0                                                                                                                                                                            |
|                                                                                                                                                                                              |
| Tuples:                                                                                                                                                                                      |
| TupleDescriptor{id=0, tbl=t01}                                                                                                                                                               |
|   SlotDescriptor{id=0, col=a, colUniqueId=0, type=decimalv3(6,3), nullable=true, isAutoIncrement=false, subColPath=null}                                                                     |
|   SlotDescriptor{id=1, col=d, colUniqueId=1, type=struct<col:bigint,col1:decimalv3(7,2)>, nullable=true, isAutoIncrement=false, subColPath=null}                                             |
|                                                                                                                                                                                              |
| TupleDescriptor{id=1, tbl=t01}                                                                                                                                                               |
|   SlotDescriptor{id=2, col=null, colUniqueId=null, type=struct<col_11:decimalv3(6,3),col_12:struct<col:bigint,col1:decimalv3(6,3)>>, nullable=false, isAutoIncrement=false, subColPath=null} |
|                                                                                                                                                                                              |
|                                                                                                                                                                                              |
|
```
@github-actions github-actions bot requested a review from dataroaring as a code owner March 18, 2025 06:14
@Thearas
Copy link
Contributor

Thearas commented Mar 18, 2025

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?

@dataroaring dataroaring reopened this Mar 18, 2025
@Thearas
Copy link
Contributor

Thearas commented Mar 18, 2025

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17582	6740	6588	6588
q2	2049	165	162	162
q3	10638	1079	1129	1079
q4	10571	758	711	711
q5	7734	2903	2846	2846
q6	218	135	131	131
q7	972	621	612	612
q8	9363	1879	2011	1879
q9	6647	6400	6355	6355
q10	7028	2277	2322	2277
q11	479	258	257	257
q12	404	217	214	214
q13	17770	2993	3028	2993
q14	245	207	213	207
q15	510	470	449	449
q16	672	600	577	577
q17	969	627	600	600
q18	7300	6668	6620	6620
q19	1453	1091	1052	1052
q20	480	209	200	200
q21	4096	3204	3305	3204
q22	1126	1028	1000	1000
Total cold run time: 108306 ms
Total hot run time: 40013 ms

----- Round 2, with runtime_filter_mode=off -----
q1	6665	6581	6577	6577
q2	329	233	230	230
q3	2891	2842	2995	2842
q4	2052	1816	1813	1813
q5	5813	5765	5854	5765
q6	213	127	128	127
q7	2269	1821	1821	1821
q8	3412	3578	3543	3543
q9	8759	8881	8891	8881
q10	3583	3528	3552	3528
q11	590	495	497	495
q12	821	613	609	609
q13	7690	3309	3164	3164
q14	297	273	274	273
q15	504	464	467	464
q16	708	662	647	647
q17	1850	1657	1606	1606
q18	8379	7693	7761	7693
q19	1668	1648	1550	1550
q20	2159	1850	1927	1850
q21	5461	5540	5465	5465
q22	1163	1092	1039	1039
Total cold run time: 67276 ms
Total hot run time: 59982 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 196909 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 e15ea44b483acd455cccd8bd3e21995afc86b817, data reload: false

query1	1298	930	923	923
query2	6239	2155	2130	2130
query3	10967	4551	4440	4440
query4	33087	23869	23393	23393
query5	5004	461	447	447
query6	276	171	178	171
query7	4007	315	319	315
query8	282	213	216	213
query9	9630	2589	2573	2573
query10	505	266	252	252
query11	18179	15135	15113	15113
query12	164	101	104	101
query13	1551	422	416	416
query14	9801	6519	7602	6519
query15	268	188	186	186
query16	8090	531	505	505
query17	1564	608	588	588
query18	2142	326	330	326
query19	339	167	161	161
query20	128	116	118	116
query21	208	108	106	106
query22	4935	4479	4458	4458
query23	34933	33977	34086	33977
query24	11034	2956	2936	2936
query25	648	412	415	412
query26	1023	170	169	169
query27	2373	349	360	349
query28	8233	2498	2448	2448
query29	854	475	459	459
query30	282	174	163	163
query31	1043	831	840	831
query32	100	56	57	56
query33	815	298	301	298
query34	1073	523	537	523
query35	876	732	739	732
query36	1103	947	983	947
query37	132	68	70	68
query38	4149	4009	4084	4009
query39	1713	1448	1451	1448
query40	218	99	99	99
query41	48	48	51	48
query42	118	113	104	104
query43	546	489	507	489
query44	1316	807	823	807
query45	182	177	168	168
query46	1169	719	738	719
query47	2043	1948	1950	1948
query48	490	387	389	387
query49	996	405	405	405
query50	853	432	420	420
query51	7201	7333	7160	7160
query52	102	86	88	86
query53	261	186	192	186
query54	1581	488	474	474
query55	83	79	78	78
query56	276	257	242	242
query57	1244	1083	1087	1083
query58	222	207	203	203
query59	3412	3120	3005	3005
query60	281	249	250	249
query61	105	121	103	103
query62	838	660	675	660
query63	228	194	192	192
query64	4096	681	636	636
query65	3276	3183	3209	3183
query66	789	316	298	298
query67	15920	15585	15673	15585
query68	4556	584	564	564
query69	439	263	263	263
query70	1192	1063	1126	1063
query71	342	265	254	254
query72	6275	4033	4037	4033
query73	754	350	341	341
query74	10384	9028	9014	9014
query75	3357	2631	2701	2631
query76	2749	1058	1016	1016
query77	385	268	282	268
query78	10530	9710	9640	9640
query79	2431	603	610	603
query80	1145	424	427	424
query81	576	242	241	241
query82	935	85	84	84
query83	223	146	147	146
query84	237	80	74	74
query85	1367	321	294	294
query86	419	309	302	302
query87	4441	4375	4326	4326
query88	4256	2376	2364	2364
query89	410	291	302	291
query90	2058	183	185	183
query91	195	149	148	148
query92	66	47	47	47
query93	2342	561	569	561
query94	950	291	304	291
query95	363	263	258	258
query96	615	286	289	286
query97	3293	3173	3136	3136
query98	222	208	194	194
query99	1560	1275	1301	1275
Total cold run time: 306009 ms
Total hot run time: 196909 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.06	0.03	0.03
query3	0.24	0.06	0.06
query4	1.64	0.10	0.10
query5	0.54	0.49	0.51
query6	1.13	0.74	0.73
query7	0.04	0.02	0.02
query8	0.04	0.03	0.04
query9	0.56	0.51	0.49
query10	0.55	0.55	0.54
query11	0.15	0.11	0.11
query12	0.14	0.11	0.11
query13	0.60	0.60	0.60
query14	2.81	2.74	2.78
query15	0.89	0.82	0.82
query16	0.37	0.38	0.38
query17	1.07	1.03	1.04
query18	0.25	0.21	0.23
query19	1.91	1.77	2.07
query20	0.01	0.01	0.01
query21	15.36	0.57	0.56
query22	3.18	2.30	1.68
query23	17.00	1.04	0.78
query24	3.09	1.02	1.48
query25	0.14	0.19	0.08
query26	0.35	0.14	0.14
query27	0.04	0.04	0.06
query28	10.09	0.52	0.52
query29	12.58	3.26	3.23
query30	0.24	0.06	0.07
query31	2.86	0.40	0.37
query32	3.24	0.46	0.46
query33	2.97	2.99	3.01
query34	17.03	4.49	4.54
query35	4.59	4.58	4.52
query36	0.66	0.49	0.51
query37	0.09	0.06	0.07
query38	0.04	0.04	0.03
query39	0.03	0.02	0.02
query40	0.15	0.12	0.13
query41	0.08	0.02	0.02
query42	0.04	0.03	0.02
query43	0.03	0.03	0.03
Total cold run time: 106.92 s
Total hot run time: 32.03 s

Copy link
Contributor

@dataroaring dataroaring left a comment

Choose a reason for hiding this comment

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

LGTM

@dataroaring dataroaring merged commit 522d378 into branch-3.0 Mar 18, 2025
22 of 24 checks passed
@github-actions github-actions bot deleted the auto-pick-48964-branch-3.0 branch March 18, 2025 09:40
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.

4 participants