Skip to content

Conversation

@superdiaodiao
Copy link
Contributor

@superdiaodiao superdiaodiao commented May 4, 2024

Proposed changes

Issue Number: #32755

Like PR: #32746, we enhanced floor/ceil/round/round_bankers can use column as scale argument.

Meanwhile, we moved these round based function register into new file named round.cpp to accelerate compile process and enable code more readable.

What's more, we made truncate() can run with single const argument avoiding BE crash, like branch2.0's behavior or Clickhouse's.

Docs refer PR: apache/doris-website#620

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@doris-robot
Copy link

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

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2024

clang-tidy review says "All clean, LGTM! 👍"

@superdiaodiao
Copy link
Contributor Author

run buildall

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2024

clang-tidy review says "All clean, LGTM! 👍"

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 35.68% (8965/25126)
Line Coverage: 27.29% (73967/271061)
Region Coverage: 26.48% (38221/144326)
Branch Coverage: 23.24% (19475/83810)
Coverage Report: http://coverage.selectdb-in.cc/coverage/472f4dbbe9c8db0e18c227e21040096e911d535b_472f4dbbe9c8db0e18c227e21040096e911d535b/report/index.html

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17631	4377	4354	4354
q2	2023	183	191	183
q3	10496	1135	1159	1135
q4	10201	738	836	738
q5	7470	2674	2740	2674
q6	220	138	138	138
q7	1031	615	609	609
q8	9249	2153	2144	2144
q9	9192	6755	6687	6687
q10	9438	3900	3859	3859
q11	434	239	247	239
q12	514	237	225	225
q13	18124	3169	3212	3169
q14	269	206	226	206
q15	516	480	461	461
q16	508	404	383	383
q17	965	738	733	733
q18	8220	7796	7669	7669
q19	1665	1555	1555	1555
q20	638	314	303	303
q21	5290	3426	4413	3426
q22	359	293	285	285
Total cold run time: 114453 ms
Total hot run time: 41175 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4542	4422	4403	4403
q2	383	277	284	277
q3	3195	2929	2913	2913
q4	1892	1594	1598	1594
q5	5427	5449	5476	5449
q6	218	121	130	121
q7	2306	1985	2019	1985
q8	3275	3471	3436	3436
q9	8663	8670	8711	8670
q10	3995	3686	3891	3686
q11	583	492	499	492
q12	804	634	660	634
q13	15719	3123	3159	3123
q14	309	260	262	260
q15	524	486	477	477
q16	503	441	438	438
q17	1786	1525	1490	1490
q18	7783	7582	7555	7555
q19	1703	1499	1512	1499
q20	1971	1754	1762	1754
q21	10101	4939	4906	4906
q22	583	506	494	494
Total cold run time: 76265 ms
Total hot run time: 55656 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 186675 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 472f4dbbe9c8db0e18c227e21040096e911d535b, data reload: false

query1	908	367	347	347
query2	7011	2404	2225	2225
query3	6655	215	213	213
query4	22890	21365	21237	21237
query5	4107	412	419	412
query6	280	192	180	180
query7	4583	297	284	284
query8	237	189	185	185
query9	8472	2333	2308	2308
query10	431	247	254	247
query11	14804	14132	14137	14132
query12	133	89	91	89
query13	1666	366	386	366
query14	10484	7644	7381	7381
query15	229	182	174	174
query16	7754	284	267	267
query17	1705	569	553	553
query18	1970	290	291	290
query19	211	153	153	153
query20	96	86	87	86
query21	199	127	129	127
query22	5159	5003	4981	4981
query23	33720	33297	33023	33023
query24	6385	2849	2911	2849
query25	511	385	384	384
query26	696	156	150	150
query27	1834	319	315	315
query28	3677	2035	2016	2016
query29	882	617	610	610
query30	235	155	158	155
query31	940	731	741	731
query32	64	53	54	53
query33	501	258	255	255
query34	888	487	490	487
query35	761	661	694	661
query36	1035	878	911	878
query37	103	68	68	68
query38	3145	3021	2993	2993
query39	1620	1543	1542	1542
query40	203	129	127	127
query41	48	40	40	40
query42	105	94	99	94
query43	579	557	522	522
query44	1092	752	748	748
query45	267	269	264	264
query46	1093	723	736	723
query47	2007	1877	1903	1877
query48	385	310	305	305
query49	856	398	397	397
query50	781	407	391	391
query51	6743	6710	6619	6619
query52	98	88	90	88
query53	356	291	282	282
query54	256	230	233	230
query55	74	72	81	72
query56	245	222	217	217
query57	1237	1141	1135	1135
query58	215	193	193	193
query59	3336	3218	3041	3041
query60	253	221	234	221
query61	88	86	85	85
query62	594	458	445	445
query63	308	283	281	281
query64	7642	7250	7196	7196
query65	3080	3059	3037	3037
query66	787	335	330	330
query67	15847	15075	15005	15005
query68	9212	539	552	539
query69	580	317	309	309
query70	1185	1041	1131	1041
query71	464	264	270	264
query72	7657	2507	2370	2370
query73	824	321	325	321
query74	6487	6134	6089	6089
query75	4491	2651	2632	2632
query76	4949	1069	935	935
query77	743	275	257	257
query78	11137	10223	10336	10223
query79	10490	518	501	501
query80	1385	434	421	421
query81	475	218	224	218
query82	745	95	91	91
query83	200	170	161	161
query84	271	83	87	83
query85	933	270	264	264
query86	375	302	313	302
query87	3364	3070	3056	3056
query88	5181	2426	2421	2421
query89	539	388	374	374
query90	2009	191	188	188
query91	129	100	101	100
query92	60	47	48	47
query93	6746	530	501	501
query94	982	179	183	179
query95	1099	1101	1102	1101
query96	622	273	271	271
query97	3144	2990	2969	2969
query98	239	220	220	220
query99	1264	877	855	855
Total cold run time: 293537 ms
Total hot run time: 186675 ms

@superdiaodiao
Copy link
Contributor Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 35.67% (8963/25126)
Line Coverage: 27.28% (73957/271061)
Region Coverage: 26.48% (38214/144326)
Branch Coverage: 23.23% (19473/83810)
Coverage Report: http://coverage.selectdb-in.cc/coverage/ef697bb10496330062dd5e2f0520afce23a044f8_ef697bb10496330062dd5e2f0520afce23a044f8/report/index.html

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17920	4294	4171	4171
q2	2012	197	190	190
q3	10468	1179	1146	1146
q4	10190	797	803	797
q5	7437	2732	2653	2653
q6	223	136	135	135
q7	1058	613	606	606
q8	9231	2164	2077	2077
q9	9359	6708	6777	6708
q10	9595	3892	3924	3892
q11	455	244	250	244
q12	446	238	231	231
q13	18678	3291	3055	3055
q14	273	231	230	230
q15	516	471	477	471
q16	481	410	391	391
q17	993	676	750	676
q18	8367	7839	7786	7786
q19	2827	1586	1577	1577
q20	665	325	314	314
q21	5387	4216	4212	4212
q22	369	292	294	292
Total cold run time: 116950 ms
Total hot run time: 41854 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4551	4360	4378	4360
q2	375	267	281	267
q3	3240	2827	2784	2784
q4	1887	1678	1624	1624
q5	5504	5530	5491	5491
q6	212	126	129	126
q7	2335	1976	1920	1920
q8	3227	3418	3398	3398
q9	8769	8728	8548	8548
q10	4078	3824	3843	3824
q11	605	492	483	483
q12	815	619	607	607
q13	17306	3125	3015	3015
q14	300	248	261	248
q15	502	486	484	484
q16	466	428	418	418
q17	1782	1482	1436	1436
q18	7648	7550	7383	7383
q19	1681	1568	1567	1567
q20	1976	1770	1740	1740
q21	8149	4928	4934	4928
q22	556	486	513	486
Total cold run time: 75964 ms
Total hot run time: 55137 ms

@doris-robot
Copy link

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

query1	902	356	348	348
query2	6420	2395	2347	2347
query3	6732	242	210	210
query4	23141	21395	21201	21201
query5	4115	428	428	428
query6	289	187	194	187
query7	4602	300	284	284
query8	255	202	199	199
query9	8440	2315	2304	2304
query10	445	254	261	254
query11	14797	14152	14119	14119
query12	143	91	89	89
query13	1665	382	365	365
query14	10592	8368	7439	7439
query15	259	171	183	171
query16	8086	257	272	257
query17	1699	590	539	539
query18	2102	285	272	272
query19	307	146	148	146
query20	93	90	85	85
query21	189	128	125	125
query22	4988	4816	4745	4745
query23	33797	33149	33112	33112
query24	6517	2929	2800	2800
query25	559	363	373	363
query26	689	154	144	144
query27	1885	313	321	313
query28	3565	1994	1981	1981
query29	834	613	627	613
query30	259	154	155	154
query31	962	731	722	722
query32	89	52	53	52
query33	476	248	256	248
query34	893	475	476	475
query35	767	679	664	664
query36	1008	917	913	913
query37	102	69	69	69
query38	3138	3057	2998	2998
query39	1582	1536	1556	1536
query40	194	137	127	127
query41	43	40	39	39
query42	105	97	98	97
query43	574	552	530	530
query44	1069	730	748	730
query45	280	256	256	256
query46	1066	726	707	707
query47	1941	1845	1864	1845
query48	376	297	287	287
query49	845	394	396	394
query50	778	396	390	390
query51	6840	6657	6729	6657
query52	104	91	98	91
query53	356	291	282	282
query54	277	301	248	248
query55	86	76	72	72
query56	250	222	225	222
query57	1184	1126	1145	1126
query58	226	205	209	205
query59	3365	3225	3140	3140
query60	261	247	237	237
query61	90	90	93	90
query62	631	452	434	434
query63	307	280	287	280
query64	8369	7296	7198	7198
query65	3112	3073	3075	3073
query66	791	344	346	344
query67	15283	14850	14948	14850
query68	5294	518	521	518
query69	476	320	307	307
query70	1094	1129	1145	1129
query71	360	279	274	274
query72	7972	2570	2384	2384
query73	696	328	334	328
query74	6429	6075	6037	6037
query75	3330	2662	2658	2658
query76	2865	1023	962	962
query77	383	267	267	267
query78	11147	10259	10158	10158
query79	2732	513	521	513
query80	1894	427	436	427
query81	515	220	225	220
query82	784	98	91	91
query83	282	169	171	169
query84	266	85	91	85
query85	1590	286	296	286
query86	489	308	304	304
query87	3264	3078	3072	3072
query88	4253	2414	2427	2414
query89	478	379	376	376
query90	2059	186	187	186
query91	126	98	99	98
query92	66	48	47	47
query93	4008	510	496	496
query94	1194	194	191	191
query95	405	308	309	308
query96	591	270	265	265
query97	3129	2978	2909	2909
query98	249	222	218	218
query99	1251	899	874	874
Total cold run time: 275857 ms
Total hot run time: 185793 ms

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2024

clang-tidy review says "All clean, LGTM! 👍"

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2024

clang-tidy review says "All clean, LGTM! 👍"

@superdiaodiao
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 35.68% (8965/25126)
Line Coverage: 27.29% (73985/271061)
Region Coverage: 26.48% (38219/144326)
Branch Coverage: 23.24% (19480/83810)
Coverage Report: http://coverage.selectdb-in.cc/coverage/adb88e93bfac34cf9795448b4508613abd41aed3_adb88e93bfac34cf9795448b4508613abd41aed3/report/index.html

@doris-robot
Copy link

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

query1	899	359	340	340
query2	6146	2356	2328	2328
query3	6869	207	205	205
query4	27572	21813	21888	21813
query5	3860	442	437	437
query6	266	188	186	186
query7	4541	297	297	297
query8	235	195	190	190
query9	8743	2369	2387	2369
query10	403	252	257	252
query11	15290	14934	14787	14787
query12	121	82	97	82
query13	1623	380	383	380
query14	9975	7405	7381	7381
query15	261	179	165	165
query16	8193	268	262	262
query17	1688	590	562	562
query18	2101	286	273	273
query19	322	153	155	153
query20	90	87	83	83
query21	202	122	122	122
query22	5087	4800	4787	4787
query23	34101	33076	33051	33051
query24	10717	2892	2989	2892
query25	610	383	380	380
query26	1178	160	150	150
query27	2333	322	310	310
query28	7066	1972	1978	1972
query29	879	616	709	616
query30	245	146	150	146
query31	948	723	724	723
query32	94	50	50	50
query33	738	251	246	246
query34	1032	465	465	465
query35	794	654	662	654
query36	1049	921	904	904
query37	131	63	63	63
query38	3163	3015	3024	3015
query39	1580	1539	1510	1510
query40	202	123	119	119
query41	40	37	39	37
query42	105	96	99	96
query43	561	541	505	505
query44	1279	737	744	737
query45	265	253	259	253
query46	1075	729	706	706
query47	1944	1836	1837	1836
query48	367	299	297	297
query49	882	410	394	394
query50	793	386	374	374
query51	6768	6667	6643	6643
query52	101	84	91	84
query53	348	274	284	274
query54	310	229	237	229
query55	79	73	72	72
query56	249	222	216	216
query57	1211	1132	1151	1132
query58	243	210	208	208
query59	3210	3404	3268	3268
query60	254	234	231	231
query61	89	88	91	88
query62	671	472	438	438
query63	313	271	278	271
query64	8652	7210	7213	7210
query65	3098	3043	3079	3043
query66	802	334	376	334
query67	15783	14750	15193	14750
query68	9588	550	548	548
query69	598	306	305	305
query70	1333	1054	1102	1054
query71	518	262	266	262
query72	8438	2564	2345	2345
query73	1555	318	329	318
query74	6554	6020	6005	6005
query75	4713	2676	2610	2610
query76	5663	961	1013	961
query77	657	268	267	267
query78	11196	10200	10061	10061
query79	12043	528	503	503
query80	1559	452	438	438
query81	498	249	223	223
query82	285	93	100	93
query83	200	167	171	167
query84	264	87	85	85
query85	953	264	266	264
query86	342	315	308	308
query87	3286	3047	3022	3022
query88	5198	2428	2434	2428
query89	524	381	379	379
query90	2072	188	189	188
query91	126	102	97	97
query92	59	49	49	49
query93	7052	520	494	494
query94	1291	186	185	185
query95	398	311	304	304
query96	590	269	267	267
query97	3114	2944	2931	2931
query98	251	227	217	217
query99	1162	851	896	851
Total cold run time: 312919 ms
Total hot run time: 186675 ms

@superdiaodiao
Copy link
Contributor Author

If we use default implementation for const for round like functions, we will never meet two const arguments in execute_impl, since this property is discarded by common logical.

Oh, you get the point. No wonder I just wanted to print the log but got nothing. Thanks~~~

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2024

clang-tidy review says "All clean, LGTM! 👍"

@superdiaodiao
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 35.61% (8962/25168)
Line Coverage: 27.29% (73975/271111)
Region Coverage: 26.50% (38203/144137)
Branch Coverage: 23.32% (19475/83520)
Coverage Report: http://coverage.selectdb-in.cc/coverage/246a386afb77fc6c94a82e53f88ef984216c87f7_246a386afb77fc6c94a82e53f88ef984216c87f7/report/index.html

@doris-robot
Copy link

TPC-DS: Total hot run time: 187296 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 246a386afb77fc6c94a82e53f88ef984216c87f7, data reload: false

query1	916	359	344	344
query2	6184	2563	2480	2480
query3	6635	213	206	206
query4	23176	21880	21867	21867
query5	3804	435	424	424
query6	264	182	174	174
query7	4544	291	290	290
query8	235	185	179	179
query9	8438	2397	2393	2393
query10	414	246	255	246
query11	15204	14684	14728	14684
query12	120	87	86	86
query13	1666	379	376	376
query14	10433	7397	7522	7397
query15	256	173	169	169
query16	8168	260	265	260
query17	1708	567	556	556
query18	2090	276	273	273
query19	252	154	152	152
query20	95	83	86	83
query21	198	122	126	122
query22	5193	4898	5021	4898
query23	33824	33111	33163	33111
query24	10583	2897	2850	2850
query25	629	384	379	379
query26	1154	154	148	148
query27	2374	316	308	308
query28	7440	2060	2034	2034
query29	867	623	612	612
query30	247	150	149	149
query31	950	786	723	723
query32	85	50	51	50
query33	734	242	237	237
query34	1069	478	488	478
query35	789	660	666	660
query36	1047	913	889	889
query37	136	63	68	63
query38	3156	3017	3001	3001
query39	1614	1560	1647	1560
query40	206	124	134	124
query41	40	39	37	37
query42	103	93	95	93
query43	573	576	550	550
query44	1218	714	733	714
query45	269	253	250	250
query46	1071	688	712	688
query47	1969	1902	1912	1902
query48	364	289	292	289
query49	893	384	382	382
query50	761	384	382	382
query51	6866	6644	6749	6644
query52	101	99	90	90
query53	341	280	275	275
query54	308	232	230	230
query55	78	76	69	69
query56	242	216	213	213
query57	1206	1154	1147	1147
query58	222	193	198	193
query59	3520	3175	3157	3157
query60	244	225	232	225
query61	107	86	84	84
query62	646	445	447	445
query63	296	278	276	276
query64	8577	7225	7145	7145
query65	3113	3011	3062	3011
query66	833	324	348	324
query67	15867	14939	14906	14906
query68	9432	546	540	540
query69	547	314	313	313
query70	1281	1169	1108	1108
query71	516	266	264	264
query72	8115	2532	2335	2335
query73	1428	314	314	314
query74	6534	6140	6218	6140
query75	4688	2612	2662	2612
query76	5517	984	1014	984
query77	664	263	262	262
query78	11121	10373	10268	10268
query79	11563	514	515	514
query80	1981	424	428	424
query81	499	218	219	218
query82	239	92	89	89
query83	217	162	161	161
query84	263	83	81	81
query85	1109	255	262	255
query86	351	292	312	292
query87	3351	3122	3099	3099
query88	5157	2344	2315	2315
query89	510	372	370	370
query90	2377	182	180	180
query91	133	95	94	94
query92	57	47	47	47
query93	7347	508	504	504
query94	1525	180	183	180
query95	401	311	308	308
query96	621	267	258	258
query97	3166	2945	2968	2945
query98	236	211	214	211
query99	1119	873	855	855
Total cold run time: 308790 ms
Total hot run time: 187296 ms

@zhiqiang-hhhh
Copy link
Contributor

https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ceil

ceil function in mysql and pg do not support using second argument.

So, @superdiaodiao could you please do a small modification so that we can detect the above situation for function ceil?

Just need to modify the logic in planner and do not register two argument for ceil on BE.

@superdiaodiao
Copy link
Contributor Author

superdiaodiao commented May 6, 2024

https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ceil

ceil function in mysql and pg do not support using second argument.

So, @superdiaodiao could you please do a small modification so that we can detect the above situation for function ceil?

Just need to modify the logic in planner and do not register two argument for ceil on BE.

Doris has been support two arguments for a long time, I think we shouldn't delete this behavior in this enhancement PR. What's more, Clickhouse also supports two argument on ceil().

@zhiqiang-hhhh
Copy link
Contributor

https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ceil
ceil function in mysql and pg do not support using second argument.
So, @superdiaodiao could you please do a small modification so that we can detect the above situation for function ceil?
Just need to modify the logic in planner and do not register two argument for ceil on BE.

Doris has been two arguments for a long time, I think we shouldn't delete this behavior in this enhancement PR. What's more, Clickhouse supports two argument on ceil();

ok, we can keep the code in this pr, and we can change behavior in another pr if necessary.

@superdiaodiao
Copy link
Contributor Author

https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ceil
ceil function in mysql and pg do not support using second argument.
So, @superdiaodiao could you please do a small modification so that we can detect the above situation for function ceil?
Just need to modify the logic in planner and do not register two argument for ceil on BE.

Doris has been two arguments for a long time, I think we shouldn't delete this behavior in this enhancement PR. What's more, Clickhouse supports two argument on ceil();

ok, we can keep the code in this pr, and we can change behavior in another pr if necessary.

Yes, I agree with this.

Copy link
Contributor

@zhiqiang-hhhh zhiqiang-hhhh left a comment

Choose a reason for hiding this comment

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

LGTM, excellent job

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2024

PR approved by anyone and no changes requested.

@superdiaodiao
Copy link
Contributor Author

run feut

Copy link
Contributor

@HappenLee HappenLee left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label May 6, 2024
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2024

PR approved by at least one committer and no changes requested.

Copy link
Contributor

@lide-reed lide-reed left a comment

Choose a reason for hiding this comment

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

LGTM

@yiguolei yiguolei merged commit 9c3d227 into apache:master May 6, 2024
yiguolei pushed a commit that referenced this pull request May 6, 2024
ByteYue pushed a commit to ByteYue/doris that referenced this pull request May 15, 2024
924060929 added a commit that referenced this pull request Aug 5, 2025
1. fix compute wrong scale of
round_bankers/truncate/round/dround/floor/dfloor/ceil/dceil, introduced
by #32746 and #34391

this sql will throw exception:
```sql
create table test_round_bankers_scale(
  id bigint,
  a decimal(32,6)
)
properties ("replication_num" = "1");

select round_bankers(a, 1-2)
from test_round_bankers_scale
order by id

(1105, 'errCode = 2, detailMessage = (172.20.48.119)[INTERNAL_ERROR]output type not match expr type  , col name  , expected type Nullable(Decimal(32, 6)) , real type Nullable(Decimal(32, 0))')
```

The scale of return type of the round_bankers function depends on the
type of its arguments. If the second argument is an integer constant,
that constant is used as the scale. If it is not a constant, the scale
of the first argument is used instead. This leads to a problem: for
expressions like `1 - 2`, the scale used in the computation differs
before and after constant folding, which can cause the Backend to throw
an exception: type mismatch

So we need to fold the arguments into constants before binding the
function, to ensure that the scale will not change

2. keep idempotent of function signature. when we select a signature for
a function, we should not change signature after do some rewrite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/2.1.3-merged dev/3.0.0-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants