Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat](Nereids) add numeric functions #40744

Merged
merged 10 commits into from
Sep 30, 2024

Conversation

LiBinfeng-01
Copy link
Collaborator

@LiBinfeng-01 LiBinfeng-01 commented Sep 12, 2024

add fold constant on fe of numeric functions:
Coalesce, Round, Ceil, Floor, Exp, Ln, Log, Log10, Log2, Sqrt, Power, Sin, Cos, Tan, Acos, Asin, Atan, Atan2, Sign, Bin, BitCount, BitLength, Cbrt, Cosh, Tanh, Dexp, Dlog10, Dlog1, Dpow, Dsqrt, Fmod, Fpow, Radians, Degrees, Xor, Pi, E, Conv, Truncate, CountEqual, Pmod.

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

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17629	7331	7208	7208
q2	2035	188	203	188
q3	10457	1358	1391	1358
q4	10402	1004	1059	1004
q5	8308	3242	3166	3166
q6	241	155	150	150
q7	1049	641	652	641
q8	9469	2017	2004	2004
q9	6758	6297	6362	6297
q10	7029	2527	2551	2527
q11	426	257	258	257
q12	407	232	230	230
q13	17764	3077	3041	3041
q14	290	252	253	252
q15	601	542	539	539
q16	513	423	434	423
q17	999	940	946	940
q18	7604	6731	6872	6731
q19	1380	1234	1228	1228
q20	606	358	333	333
q21	3886	3533	3491	3491
q22	1085	997	1030	997
Total cold run time: 108938 ms
Total hot run time: 43005 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7193	7196	7144	7144
q2	337	232	232	232
q3	2902	2921	2920	2920
q4	1950	1938	1949	1938
q5	5462	5436	5438	5436
q6	234	143	142	142
q7	2030	1692	1662	1662
q8	3235	3305	3341	3305
q9	8451	8404	8409	8404
q10	3428	3462	3483	3462
q11	582	472	469	469
q12	771	591	562	562
q13	9835	3060	3086	3060
q14	298	274	275	274
q15	563	520	517	517
q16	485	453	452	452
q17	1755	1699	1669	1669
q18	8039	7518	7711	7518
q19	1713	1689	1690	1689
q20	2021	1801	1805	1801
q21	5581	5406	5563	5406
q22	1124	1020	997	997
Total cold run time: 67989 ms
Total hot run time: 59059 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 195717 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 76a098e407d90eaee4f428c5ca3330c59ba02ee9, data reload: false

query1	923	380	373	373
query2	6511	1844	1835	1835
query3	6665	212	231	212
query4	27070	24186	24092	24092
query5	5449	542	538	538
query6	261	181	201	181
query7	4602	307	308	307
query8	284	247	228	228
query9	8529	2565	2548	2548
query10	491	299	287	287
query11	16435	15669	15785	15669
query12	154	104	99	99
query13	1682	404	390	390
query14	11762	6903	6791	6791
query15	227	166	174	166
query16	7586	492	490	490
query17	1554	580	575	575
query18	1992	304	295	295
query19	196	148	147	147
query20	121	110	112	110
query21	209	108	106	106
query22	4450	4417	4251	4251
query23	34937	33923	33827	33827
query24	9494	3080	3068	3068
query25	677	392	399	392
query26	1591	155	158	155
query27	2861	280	290	280
query28	6846	2089	2073	2073
query29	1047	411	419	411
query30	300	155	147	147
query31	979	783	813	783
query32	109	57	56	56
query33	746	304	295	295
query34	894	495	482	482
query35	869	725	762	725
query36	1026	907	907	907
query37	164	93	84	84
query38	4137	3895	3931	3895
query39	1468	1404	1410	1404
query40	289	115	116	115
query41	48	46	46	46
query42	119	96	96	96
query43	519	447	453	447
query44	1211	795	786	786
query45	194	167	171	167
query46	1102	821	790	790
query47	1903	1776	1819	1776
query48	369	295	295	295
query49	1191	441	442	441
query50	918	432	447	432
query51	7026	7003	6952	6952
query52	110	89	89	89
query53	256	185	184	184
query54	760	461	478	461
query55	79	80	76	76
query56	279	261	267	261
query57	1195	1079	1095	1079
query58	243	249	236	236
query59	2823	2605	2698	2605
query60	300	283	268	268
query61	103	103	108	103
query62	915	673	675	673
query63	234	189	188	188
query64	5187	731	678	678
query65	3265	3197	3172	3172
query66	1398	292	303	292
query67	16035	15580	15566	15566
query68	3157	871	856	856
query69	441	334	328	328
query70	1168	1163	1134	1134
query71	345	346	347	346
query72	5902	3372	3398	3372
query73	595	582	579	579
query74	9309	9220	9070	9070
query75	3164	3016	3036	3016
query76	1856	849	848	848
query77	435	410	409	409
query78	9402	9284	9265	9265
query79	893	909	877	877
query80	851	815	821	815
query81	448	265	263	263
query82	265	266	262	262
query83	190	186	191	186
query84	243	109	108	108
query85	719	422	405	405
query86	318	320	302	302
query87	4313	4348	4496	4348
query88	4219	4131	4119	4119
query89	377	370	370	370
query90	1274	323	319	319
query91	126	131	126	126
query92	78	75	78	75
query93	1033	1024	1019	1019
query94	611	392	381	381
query95	454	426	426	426
query96	476	469	472	469
query97	3120	3132	3159	3132
query98	233	232	240	232
query99	1553	1312	1338	1312
Total cold run time: 280937 ms
Total hot run time: 195717 ms

@doris-robot
Copy link

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

query1	0.04	0.05	0.04
query2	0.07	0.04	0.04
query3	0.22	0.04	0.04
query4	1.69	0.06	0.06
query5	0.51	0.50	0.51
query6	1.14	0.74	0.74
query7	0.03	0.02	0.02
query8	0.05	0.04	0.05
query9	0.56	0.53	0.52
query10	0.56	0.57	0.56
query11	0.16	0.12	0.12
query12	0.16	0.13	0.13
query13	0.62	0.60	0.60
query14	1.47	1.46	1.46
query15	0.90	0.88	0.88
query16	0.37	0.36	0.36
query17	1.06	1.06	1.05
query18	0.22	0.20	0.21
query19	1.92	1.81	1.79
query20	0.01	0.02	0.01
query21	15.43	0.66	0.65
query22	4.77	6.93	1.25
query23	18.10	1.28	1.26
query24	2.24	0.23	0.22
query25	0.18	0.08	0.08
query26	0.29	0.18	0.17
query27	0.08	0.08	0.07
query28	13.19	1.11	1.10
query29	12.64	3.35	3.37
query30	0.24	0.05	0.05
query31	2.88	0.41	0.40
query32	3.22	0.49	0.50
query33	3.04	3.00	3.08
query34	15.46	4.33	4.34
query35	4.41	4.34	4.36
query36	0.69	0.49	0.48
query37	0.19	0.16	0.17
query38	0.17	0.15	0.16
query39	0.05	0.05	0.04
query40	0.17	0.14	0.13
query41	0.10	0.05	0.05
query42	0.06	0.05	0.05
query43	0.06	0.04	0.04
Total cold run time: 109.42 s
Total hot run time: 31.02 s

@LiBinfeng-01 LiBinfeng-01 force-pushed the fold_const_numeric branch 2 times, most recently from 37061e4 to 4d76abb Compare September 13, 2024 14:24
@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17574	7272	7219	7219
q2	2031	182	182	182
q3	10465	1280	1423	1280
q4	10486	1011	981	981
q5	7719	3180	3182	3180
q6	242	153	147	147
q7	1044	642	628	628
q8	9475	2038	2036	2036
q9	6865	6325	6339	6325
q10	7029	2524	2510	2510
q11	436	257	252	252
q12	411	232	231	231
q13	17756	3036	3008	3008
q14	295	258	254	254
q15	596	536	531	531
q16	513	428	425	425
q17	980	945	968	945
q18	7313	6832	6822	6822
q19	1389	1239	1234	1234
q20	609	337	335	335
q21	3917	3540	3515	3515
q22	1089	1003	987	987
Total cold run time: 108234 ms
Total hot run time: 43027 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7276	7198	7178	7178
q2	348	245	233	233
q3	3102	3077	3045	3045
q4	2088	2114	2017	2017
q5	5755	5606	5738	5606
q6	241	146	147	146
q7	2179	1803	1763	1763
q8	3404	3412	3405	3405
q9	8821	8880	8751	8751
q10	3474	3574	3573	3573
q11	583	475	488	475
q12	828	627	604	604
q13	9997	3205	3199	3199
q14	325	276	289	276
q15	594	540	541	540
q16	518	464	472	464
q17	1807	1766	1767	1766
q18	8628	7928	8105	7928
q19	1767	1743	1747	1743
q20	2142	1891	1891	1891
q21	5769	5723	5685	5685
q22	1135	1086	1027	1027
Total cold run time: 70781 ms
Total hot run time: 61315 ms

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17564	7320	7228	7228
q2	2039	182	182	182
q3	10462	1257	1353	1257
q4	10513	1042	1052	1042
q5	7721	3144	3136	3136
q6	241	154	151	151
q7	1039	638	623	623
q8	9461	1993	2023	1993
q9	6802	6280	6291	6280
q10	7036	2504	2518	2504
q11	447	259	259	259
q12	412	231	228	228
q13	17770	3010	3048	3010
q14	294	244	248	244
q15	598	527	522	522
q16	514	451	429	429
q17	981	945	960	945
q18	7350	6849	6846	6846
q19	1364	1265	1231	1231
q20	599	326	337	326
q21	3939	3542	3544	3542
q22	1086	975	978	975
Total cold run time: 108232 ms
Total hot run time: 42953 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7228	7226	7191	7191
q2	350	255	236	236
q3	3067	3087	3067	3067
q4	2108	2118	2045	2045
q5	5666	5650	5706	5650
q6	242	150	150	150
q7	2156	1792	1797	1792
q8	3352	3458	3405	3405
q9	8833	8890	8778	8778
q10	3458	3577	3588	3577
q11	581	485	479	479
q12	827	626	634	626
q13	8745	3196	3238	3196
q14	308	291	279	279
q15	581	538	538	538
q16	516	472	456	456
q17	1794	1758	1765	1758
q18	8496	8044	7887	7887
q19	1772	1765	1755	1755
q20	2141	1888	1879	1879
q21	5987	5469	5700	5469
q22	1124	1044	1047	1044
Total cold run time: 69332 ms
Total hot run time: 61257 ms

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17623	7400	7282	7282
q2	2031	175	153	153
q3	10649	1080	1118	1080
q4	10567	712	735	712
q5	7738	3029	3039	3029
q6	234	150	145	145
q7	993	612	600	600
q8	9426	1999	2009	1999
q9	6869	6404	6404	6404
q10	7019	2253	2299	2253
q11	443	245	250	245
q12	403	211	216	211
q13	17804	2935	2975	2935
q14	235	212	211	211
q15	579	531	508	508
q16	667	613	629	613
q17	983	758	794	758
q18	7292	6668	6600	6600
q19	1414	1039	1111	1039
q20	575	283	280	280
q21	4111	3176	3157	3157
q22	1119	998	1005	998
Total cold run time: 108774 ms
Total hot run time: 41212 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7241	7305	7212	7212
q2	317	232	220	220
q3	2996	2952	2981	2952
q4	2029	1796	1804	1796
q5	5643	5621	5566	5566
q6	234	140	152	140
q7	2261	1819	1765	1765
q8	3307	3416	3396	3396
q9	8696	8892	8780	8780
q10	3552	3427	3489	3427
q11	589	480	485	480
q12	820	605	596	596
q13	10885	3164	3135	3135
q14	309	278	283	278
q15	571	548	506	506
q16	712	677	698	677
q17	1782	1599	1607	1599
q18	8243	7860	7919	7860
q19	1720	1523	1582	1523
q20	2135	1851	1906	1851
q21	5492	5148	5293	5148
q22	1189	1031	1058	1031
Total cold run time: 70723 ms
Total hot run time: 59938 ms

@LiBinfeng-01
Copy link
Collaborator Author

run performance

@LiBinfeng-01
Copy link
Collaborator Author

run p0

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17810	8006	7355	7355
q2	2058	161	158	158
q3	12239	1151	1146	1146
q4	10417	807	692	692
q5	7750	3127	3081	3081
q6	243	155	147	147
q7	1017	623	623	623
q8	10536	2037	2046	2037
q9	6963	6544	6525	6525
q10	7141	2298	2346	2298
q11	440	256	255	255
q12	415	224	226	224
q13	19262	3046	3066	3046
q14	232	213	269	213
q15	571	523	530	523
q16	1085	640	610	610
q17	1195	858	860	858
q18	8518	6652	6631	6631
q19	1404	1019	1019	1019
q20	574	291	287	287
q21	4002	3341	3243	3243
q22	1111	1022	1008	1008
Total cold run time: 114983 ms
Total hot run time: 41979 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7280	7299	7378	7299
q2	340	236	247	236
q3	3164	2934	2994	2934
q4	2107	1758	1754	1754
q5	5604	5650	5659	5650
q6	227	148	142	142
q7	2192	1807	1802	1802
q8	3322	3395	3407	3395
q9	8873	8760	8687	8687
q10	3475	3507	3500	3500
q11	585	482	489	482
q12	810	627	637	627
q13	12614	3126	3184	3126
q14	325	264	272	264
q15	561	540	528	528
q16	720	686	682	682
q17	1824	1582	1572	1572
q18	8141	7793	7764	7764
q19	1694	1611	1578	1578
q20	2108	1877	1890	1877
q21	5559	5413	5361	5361
q22	1160	1051	1052	1051
Total cold run time: 72685 ms
Total hot run time: 60311 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 199206 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 309ada3b88104cc70cee6eda36c1a3144dfc58dd, data reload: false

query1	1300	877	868	868
query2	6379	2107	2040	2040
query3	10763	3959	3884	3884
query4	63162	29455	23421	23421
query5	5151	461	453	453
query6	397	171	165	165
query7	5452	314	295	295
query8	309	237	222	222
query9	8602	2659	2673	2659
query10	449	307	282	282
query11	17695	15014	15662	15014
query12	166	103	101	101
query13	1481	427	430	427
query14	10185	7372	7636	7372
query15	210	183	176	176
query16	6391	460	524	460
query17	1184	615	596	596
query18	844	300	311	300
query19	221	158	151	151
query20	127	109	117	109
query21	206	109	112	109
query22	4736	4564	4798	4564
query23	34668	34060	34131	34060
query24	6042	2929	2902	2902
query25	512	388	400	388
query26	637	161	163	161
query27	1626	283	287	283
query28	4187	2475	2411	2411
query29	680	440	433	433
query30	239	159	154	154
query31	972	781	809	781
query32	72	54	56	54
query33	441	293	285	285
query34	890	500	496	496
query35	878	741	745	741
query36	1030	908	937	908
query37	154	91	88	88
query38	3976	3887	4109	3887
query39	1469	1399	1376	1376
query40	213	98	97	97
query41	49	48	47	47
query42	111	95	99	95
query43	520	496	497	496
query44	1146	805	813	805
query45	196	164	163	163
query46	1119	737	767	737
query47	1946	1790	1821	1790
query48	476	364	381	364
query49	702	412	410	410
query50	840	412	499	412
query51	7105	7000	6923	6923
query52	98	85	88	85
query53	252	173	175	173
query54	573	448	448	448
query55	76	75	79	75
query56	274	250	246	246
query57	1204	1080	1064	1064
query58	215	237	235	235
query59	3417	2966	3104	2966
query60	304	264	277	264
query61	103	100	119	100
query62	745	654	659	654
query63	209	184	182	182
query64	1345	644	665	644
query65	3282	3165	3211	3165
query66	665	294	307	294
query67	16262	15642	15487	15487
query68	1577	567	560	560
query69	425	294	304	294
query70	1184	1129	1107	1107
query71	320	266	270	266
query72	6014	4003	3959	3959
query73	757	336	332	332
query74	9366	8962	9052	8962
query75	3325	2642	2718	2642
query76	1429	964	920	920
query77	476	292	291	291
query78	10212	9579	9392	9392
query79	1060	897	882	882
query80	841	586	577	577
query81	508	261	251	251
query82	1290	235	231	231
query83	237	168	162	162
query84	290	109	107	107
query85	793	367	360	360
query86	351	334	321	321
query87	4354	4341	4420	4341
query88	4412	4062	4055	4055
query89	390	359	364	359
query90	1789	312	310	310
query91	160	164	167	164
query92	75	75	71	71
query93	952	904	913	904
query94	728	366	395	366
query95	446	413	410	410
query96	484	488	484	484
query97	3240	3118	3170	3118
query98	231	220	223	220
query99	1522	1291	1317	1291
Total cold run time: 306568 ms
Total hot run time: 199206 ms

@doris-robot
Copy link

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

query1	0.05	0.05	0.05
query2	0.06	0.02	0.02
query3	0.23	0.06	0.07
query4	1.65	0.10	0.11
query5	0.53	0.48	0.51
query6	1.16	0.72	0.72
query7	0.03	0.02	0.01
query8	0.04	0.02	0.04
query9	0.55	0.51	0.50
query10	0.55	0.59	0.54
query11	0.14	0.10	0.10
query12	0.14	0.11	0.10
query13	0.60	0.60	0.59
query14	3.09	2.93	2.95
query15	0.90	0.81	0.82
query16	0.38	0.37	0.38
query17	1.06	1.06	1.05
query18	0.20	0.19	0.19
query19	1.95	1.89	2.04
query20	0.01	0.01	0.01
query21	15.36	0.61	0.59
query22	2.79	2.73	1.08
query23	17.55	0.82	0.73
query24	3.25	1.01	1.51
query25	0.18	0.13	0.09
query26	0.52	0.14	0.14
query27	0.04	0.05	0.04
query28	10.22	1.10	1.06
query29	12.55	3.29	3.28
query30	0.24	0.06	0.06
query31	2.88	0.38	0.38
query32	3.28	0.47	0.45
query33	2.96	3.03	3.01
query34	17.01	4.44	4.43
query35	4.43	4.40	4.42
query36	0.70	0.51	0.51
query37	0.08	0.06	0.06
query38	0.04	0.03	0.04
query39	0.04	0.02	0.02
query40	0.16	0.13	0.12
query41	0.08	0.03	0.02
query42	0.03	0.03	0.02
query43	0.04	0.04	0.03
Total cold run time: 107.75 s
Total hot run time: 32.1 s

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@LiBinfeng-01
Copy link
Collaborator Author

run feut

@LiBinfeng-01
Copy link
Collaborator Author

run performance

@@ -84,6 +84,12 @@ public DecimalV3Literal roundFloor(int newScale) {
value.setScale(newScale, RoundingMode.FLOOR));
}

public DecimalV3Literal round(int newScale) {
return new DecimalV3Literal(DecimalV3Type
.createDecimalV3Type(((DecimalV3Type) dataType).getPrecision(), newScale),
Copy link
Contributor

Choose a reason for hiding this comment

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

what scale should be set if newScale bigger than old scale?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

when new scale is larger than original one, it would throw an Invocationexception when calling create Decimal Type in java with message: precision should not smaller than scale and ExpressionEvaluator would catch this exception and go back to original expression. But actually when new scalar bigger than old one, we can return original one when folding constant. Same as be calculation logic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

when new scale is larger than original one, it would throw an Invocationexception when calling create Decimal Type in java with message: precision should not smaller than scale and ExpressionEvaluator would catch this exception and go back to original expression. But actually when new scalar bigger than old one, we can return original one when folding constant. Same as be calculation logic

we should not rely on exception, exception is very expensive, so we should process it without use exception

*/
@ExecFunction(name = "ceil")
public static Expression ceil(DecimalV3Literal first, IntegerLiteral second) {
return first.roundCeiling(second.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

same as round, if second > old scale, the result is wrong

Copy link
Contributor

Choose a reason for hiding this comment

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

move if into roundCeiling

*/
@ExecFunction(name = "floor")
public static Expression floor(DecimalV3Literal first, IntegerLiteral second) {
return first.roundFloor(second.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

same as ceil

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

*/
@ExecFunction(name = "exp")
public static Expression exp(DoubleLiteral first) {
return new DoubleLiteral(Math.exp(first.getValue()));
Copy link
Contributor

Choose a reason for hiding this comment

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

what will happen if result of Math.exp is infinity?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should return null literal, in java it would return infinite value when it is infinity, would return NaN when the input is Invalid like acos(-2) which input should between [-1, 1]. In sql behavior, it should return NULL, when it is NaN or infinity(positive, negative is same logic). Let me add some boundary check in some functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was wrong about Infinity, actually it should return "inf" in sql and " ∞" in explain string. NaN is right to show by NULL

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17957	7476	7315	7315
q2	2379	164	154	154
q3	11390	1165	1253	1165
q4	10298	822	749	749
q5	7763	3098	3120	3098
q6	238	151	150	150
q7	1021	628	630	628
q8	9539	2044	2063	2044
q9	6869	6387	6368	6368
q10	7004	2273	2283	2273
q11	446	260	252	252
q12	412	213	213	213
q13	17768	2998	2988	2988
q14	245	224	223	223
q15	584	535	510	510
q16	691	604	604	604
q17	973	839	770	770
q18	7354	6708	6800	6708
q19	1393	1049	1001	1001
q20	573	283	279	279
q21	4040	3246	3287	3246
q22	1094	996	990	990
Total cold run time: 110031 ms
Total hot run time: 41728 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7305	7265	7278	7265
q2	332	235	223	223
q3	2890	2761	2751	2751
q4	2059	1702	1697	1697
q5	5327	5391	5399	5391
q6	235	141	142	141
q7	2082	1723	1704	1704
q8	3181	3300	3292	3292
q9	8445	8338	8420	8338
q10	3411	3363	3338	3338
q11	576	474	478	474
q12	784	569	595	569
q13	6244	2964	3000	2964
q14	293	261	262	261
q15	555	517	518	517
q16	694	671	668	668
q17	1752	1551	1524	1524
q18	7538	7441	7321	7321
q19	1659	1658	1451	1451
q20	2030	1796	1776	1776
q21	5285	5001	5270	5001
q22	1137	1023	1022	1022
Total cold run time: 63814 ms
Total hot run time: 57688 ms

@doris-robot
Copy link

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

query1	939	392	372	372
query2	6503	2010	2020	2010
query3	6701	211	227	211
query4	36844	23447	23375	23375
query5	4357	492	481	481
query6	254	169	158	158
query7	4617	294	299	294
query8	266	222	226	222
query9	9775	2690	2652	2652
query10	473	301	284	284
query11	18123	15291	15265	15265
query12	150	97	104	97
query13	1616	410	392	392
query14	9318	7628	7503	7503
query15	295	183	176	176
query16	8020	426	483	426
query17	1747	582	570	570
query18	2114	312	306	306
query19	361	154	150	150
query20	119	110	115	110
query21	222	107	107	107
query22	4461	4249	4106	4106
query23	34642	34019	33826	33826
query24	11153	2877	2895	2877
query25	653	408	407	407
query26	1209	166	165	165
query27	2708	288	292	288
query28	7941	2472	2432	2432
query29	859	417	433	417
query30	328	170	156	156
query31	1030	787	807	787
query32	105	59	59	59
query33	775	306	294	294
query34	963	487	494	487
query35	868	743	762	743
query36	1082	939	947	939
query37	157	99	82	82
query38	4051	3913	3880	3880
query39	1466	1449	1402	1402
query40	214	98	99	98
query41	52	48	48	48
query42	125	106	100	100
query43	509	480	480	480
query44	1254	822	800	800
query45	198	167	165	165
query46	1142	765	794	765
query47	1890	1788	1846	1788
query48	461	375	367	367
query49	1140	430	410	410
query50	831	406	406	406
query51	6984	7087	6974	6974
query52	100	89	88	88
query53	259	186	183	183
query54	1317	469	473	469
query55	83	79	78	78
query56	304	268	269	268
query57	1213	1081	1100	1081
query58	254	228	241	228
query59	3086	2877	2854	2854
query60	300	294	276	276
query61	131	238	101	101
query62	879	677	678	677
query63	228	211	183	183
query64	5247	643	628	628
query65	3366	3214	3220	3214
query66	1466	333	301	301
query67	16202	15687	15484	15484
query68	3248	691	570	570
query69	437	285	287	285
query70	1213	1086	1128	1086
query71	336	273	269	269
query72	6118	4090	4014	4014
query73	760	326	338	326
query74	9819	9031	8997	8997
query75	3418	2663	2679	2663
query76	1966	931	947	931
query77	416	297	299	297
query78	9960	10473	9317	9317
query79	1085	899	870	870
query80	884	593	588	588
query81	571	256	258	256
query82	575	236	232	232
query83	206	162	177	162
query84	254	107	105	105
query85	816	382	354	354
query86	396	312	330	312
query87	4403	4348	4361	4348
query88	4438	4043	4045	4043
query89	379	371	359	359
query90	2013	315	308	308
query91	165	167	162	162
query92	83	75	75	75
query93	932	915	904	904
query94	1038	363	360	360
query95	483	413	413	413
query96	490	485	484	484
query97	3117	3183	3176	3176
query98	232	248	229	229
query99	1407	1300	1289	1289
Total cold run time: 298158 ms
Total hot run time: 194806 ms

@doris-robot
Copy link

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

query1	0.04	0.05	0.04
query2	0.06	0.03	0.03
query3	0.23	0.06	0.06
query4	1.66	0.10	0.10
query5	0.50	0.51	0.50
query6	1.14	0.72	0.73
query7	0.02	0.01	0.02
query8	0.03	0.03	0.04
query9	0.55	0.50	0.49
query10	0.55	0.57	0.54
query11	0.14	0.11	0.11
query12	0.14	0.10	0.11
query13	0.62	0.59	0.59
query14	2.98	3.03	2.97
query15	0.89	0.82	0.84
query16	0.36	0.39	0.36
query17	1.04	0.99	1.06
query18	0.22	0.20	0.21
query19	1.93	1.86	1.97
query20	0.01	0.00	0.01
query21	15.39	0.63	0.58
query22	2.76	2.46	1.94
query23	17.11	0.86	0.82
query24	2.59	1.53	1.47
query25	0.21	0.07	0.04
query26	0.56	0.15	0.15
query27	0.04	0.05	0.04
query28	10.11	1.10	1.08
query29	12.90	3.27	3.26
query30	0.25	0.06	0.06
query31	2.87	0.39	0.39
query32	3.28	0.46	0.46
query33	2.97	3.01	3.06
query34	17.17	4.40	4.38
query35	4.41	4.46	4.41
query36	0.66	0.47	0.50
query37	0.08	0.06	0.06
query38	0.04	0.03	0.03
query39	0.03	0.02	0.03
query40	0.15	0.12	0.13
query41	0.07	0.02	0.02
query42	0.03	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 106.82 s
Total hot run time: 33.38 s

morrySnow pushed a commit that referenced this pull request Oct 21, 2024
morrySnow pushed a commit that referenced this pull request Nov 12, 2024
…recision problem (#43422)

- Problem
function like ```select floor(300.343, 2)``` precision should be 5 and
scale should be 2, but now is (6, 2) after compute precision, but after
folding const on fe, it changed to (5, 2) but upper level of plan still
expect the output of child to be (6, 2). So it would rise an exception
when executing.

- How it was fixed 
fix folding constant precision of floor/round/ceil/truncate functions
from (5, 2) to (6, 2) in upper case

- Notion
when second value is negative and it absolute value >= precision -
value, it can not be expressed in fe which result is zero with decimal
type (3, 0). like 000. So just let it go back and no using folding
constant by fe.

- Related PR: #40744

- Release note
    Fix floor/round/ceil functions precision problem in folding constant
github-actions bot pushed a commit that referenced this pull request Nov 12, 2024
…recision problem (#43422)

- Problem
function like ```select floor(300.343, 2)``` precision should be 5 and
scale should be 2, but now is (6, 2) after compute precision, but after
folding const on fe, it changed to (5, 2) but upper level of plan still
expect the output of child to be (6, 2). So it would rise an exception
when executing.

- How it was fixed 
fix folding constant precision of floor/round/ceil/truncate functions
from (5, 2) to (6, 2) in upper case

- Notion
when second value is negative and it absolute value >= precision -
value, it can not be expressed in fe which result is zero with decimal
type (3, 0). like 000. So just let it go back and no using folding
constant by fe.

- Related PR: #40744

- Release note
    Fix floor/round/ceil functions precision problem in folding constant
github-actions bot pushed a commit that referenced this pull request Nov 12, 2024
…recision problem (#43422)

- Problem
function like ```select floor(300.343, 2)``` precision should be 5 and
scale should be 2, but now is (6, 2) after compute precision, but after
folding const on fe, it changed to (5, 2) but upper level of plan still
expect the output of child to be (6, 2). So it would rise an exception
when executing.

- How it was fixed 
fix folding constant precision of floor/round/ceil/truncate functions
from (5, 2) to (6, 2) in upper case

- Notion
when second value is negative and it absolute value >= precision -
value, it can not be expressed in fe which result is zero with decimal
type (3, 0). like 000. So just let it go back and no using folding
constant by fe.

- Related PR: #40744

- Release note
    Fix floor/round/ceil functions precision problem in folding constant
LiBinfeng-01 added a commit to LiBinfeng-01/doris that referenced this pull request Nov 12, 2024
…recision problem (apache#43422)

- Problem
function like ```select floor(300.343, 2)``` precision should be 5 and
scale should be 2, but now is (6, 2) after compute precision, but after
folding const on fe, it changed to (5, 2) but upper level of plan still
expect the output of child to be (6, 2). So it would rise an exception
when executing.

- How it was fixed 
fix folding constant precision of floor/round/ceil/truncate functions
from (5, 2) to (6, 2) in upper case

- Notion
when second value is negative and it absolute value >= precision -
value, it can not be expressed in fe which result is zero with decimal
type (3, 0). like 000. So just let it go back and no using folding
constant by fe.

- Related PR: apache#40744

- Release note
    Fix floor/round/ceil functions precision problem in folding constant
LiBinfeng-01 added a commit to LiBinfeng-01/doris that referenced this pull request Nov 12, 2024
…recision problem (apache#43422)

- Problem
function like ```select floor(300.343, 2)``` precision should be 5 and
scale should be 2, but now is (6, 2) after compute precision, but after
folding const on fe, it changed to (5, 2) but upper level of plan still
expect the output of child to be (6, 2). So it would rise an exception
when executing.

- How it was fixed 
fix folding constant precision of floor/round/ceil/truncate functions
from (5, 2) to (6, 2) in upper case

- Notion
when second value is negative and it absolute value >= precision -
value, it can not be expressed in fe which result is zero with decimal
type (3, 0). like 000. So just let it go back and no using folding
constant by fe.

- Related PR: apache#40744

- Release note
    Fix floor/round/ceil functions precision problem in folding constant
py023 pushed a commit to py023/doris that referenced this pull request Nov 13, 2024
…recision problem (apache#43422)

- Problem
function like ```select floor(300.343, 2)``` precision should be 5 and
scale should be 2, but now is (6, 2) after compute precision, but after
folding const on fe, it changed to (5, 2) but upper level of plan still
expect the output of child to be (6, 2). So it would rise an exception
when executing.

- How it was fixed 
fix folding constant precision of floor/round/ceil/truncate functions
from (5, 2) to (6, 2) in upper case

- Notion
when second value is negative and it absolute value >= precision -
value, it can not be expressed in fe which result is zero with decimal
type (3, 0). like 000. So just let it go back and no using folding
constant by fe.

- Related PR: apache#40744

- Release note
    Fix floor/round/ceil functions precision problem in folding constant
morrySnow pushed a commit that referenced this pull request Nov 18, 2024
…cion (#44022)

Related PR: #40744 

when executing floor(1) it would castTo decimalV3(3,0) because it need
(3,0) to contain it's message.
But after fold const, it lost precision(3) because decimalV3 literal
class does not have mechanism to save precision
Solved: after folding constant, we need to change result type to the
type we wanted
github-actions bot pushed a commit that referenced this pull request Nov 18, 2024
…cion (#44022)

Related PR: #40744 

when executing floor(1) it would castTo decimalV3(3,0) because it need
(3,0) to contain it's message.
But after fold const, it lost precision(3) because decimalV3 literal
class does not have mechanism to save precision
Solved: after folding constant, we need to change result type to the
type we wanted
github-actions bot pushed a commit that referenced this pull request Nov 18, 2024
…cion (#44022)

Related PR: #40744 

when executing floor(1) it would castTo decimalV3(3,0) because it need
(3,0) to contain it's message.
But after fold const, it lost precision(3) because decimalV3 literal
class does not have mechanism to save precision
Solved: after folding constant, we need to change result type to the
type we wanted
morrySnow pushed a commit that referenced this pull request Feb 19, 2025
…o match with be execution behavior (#47966)

### What problem does this PR solve?

Related PR: #40744#47228

Problem Summary:
When numeric function input or output out of boundary when fe folding
constant, it would throw an exception before. Now
we change it to match with be execution result, which is NullLiteral
github-actions bot pushed a commit that referenced this pull request Feb 19, 2025
…o match with be execution behavior (#47966)

### What problem does this PR solve?

Related PR: #40744#47228

Problem Summary:
When numeric function input or output out of boundary when fe folding
constant, it would throw an exception before. Now
we change it to match with be execution result, which is NullLiteral
lzyy2024 pushed a commit to lzyy2024/doris that referenced this pull request Feb 21, 2025
…o match with be execution behavior (apache#47966)

### What problem does this PR solve?

Related PR: apache#40744apache#47228

Problem Summary:
When numeric function input or output out of boundary when fe folding
constant, it would throw an exception before. Now
we change it to match with be execution result, which is NullLiteral
LiBinfeng-01 added a commit to LiBinfeng-01/doris that referenced this pull request Feb 24, 2025
…o match with be execution behavior (apache#47966)

Related PR: apache#40744apache#47228

Problem Summary:
When numeric function input or output out of boundary when fe folding
constant, it would throw an exception before. Now
we change it to match with be execution result, which is NullLiteral
LiBinfeng-01 added a commit to LiBinfeng-01/doris that referenced this pull request Feb 25, 2025
…o match with be execution behavior (apache#47966)

### What problem does this PR solve?

Related PR: apache#40744apache#47228

Problem Summary:
When numeric function input or output out of boundary when fe folding
constant, it would throw an exception before. Now
we change it to match with be execution result, which is NullLiteral
yiguolei pushed a commit that referenced this pull request Feb 25, 2025
…y behavior to match with be execution behavior #47966 (#48237)

pick:#47966

Related PR: #40744#47228

Problem Summary:
When numeric function input or output out of boundary when fe folding
constant, it would throw an exception before. Now
we change it to match with be execution result, which is NullLiteral

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] 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 <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
dataroaring pushed a commit that referenced this pull request Feb 26, 2025
…y behavior to match with be execution behavior (#47966) (#48281)

pick:#47966
### What problem does this PR solve?

Related PR: #40744#47228

Problem Summary:
When numeric function input or output out of boundary when fe folding
constant, it would throw an exception before. Now
we change it to match with be execution result, which is NullLiteral
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.7-merged dev/3.0.3-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants