Skip to content

Conversation

@924060929
Copy link
Contributor

cherry pick from #50142

…pache#50142)

fix fold constant return wrong scale of datetime type

for example, this sql should return data type `datatime(6)`, but the
fold constant rule will direct return the first argument, so return the
wrong data type `datetime(0)`
```sql
select nvl(cast('2025-04-17 01:02:03' as datetime(0)), cast('2025-04-17 01:02:03.123456' as datetime(6)))
```

(cherry picked from commit c679c83)
@924060929 924060929 requested a review from dataroaring as a code owner May 8, 2025 12:30
@Thearas
Copy link
Contributor

Thearas commented May 8, 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?

@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17581	6865	6564	6564
q2	2048	179	163	163
q3	10580	1097	1151	1097
q4	10490	749	661	661
q5	7787	2922	2818	2818
q6	216	135	141	135
q7	978	621	616	616
q8	9364	1991	2044	1991
q9	6522	6396	6376	6376
q10	7050	2308	2299	2299
q11	474	263	268	263
q12	401	213	209	209
q13	18046	2987	3007	2987
q14	228	214	209	209
q15	502	465	461	461
q16	670	606	594	594
q17	1010	579	554	554
q18	7280	6710	6856	6710
q19	1413	1052	1084	1052
q20	477	202	200	200
q21	4426	3226	3330	3226
q22	1106	1002	980	980
Total cold run time: 108649 ms
Total hot run time: 40165 ms

----- Round 2, with runtime_filter_mode=off -----
q1	6616	6600	6572	6572
q2	327	236	233	233
q3	2979	2807	2988	2807
q4	2044	1872	1826	1826
q5	5881	5856	5847	5847
q6	213	128	128	128
q7	2244	1875	1831	1831
q8	3447	3587	3508	3508
q9	9122	9216	9236	9216
q10	3658	3814	3643	3643
q11	618	512	493	493
q12	846	696	665	665
q13	13813	3195	3235	3195
q14	318	287	279	279
q15	520	464	464	464
q16	717	681	657	657
q17	1890	1670	1581	1581
q18	8331	7795	7761	7761
q19	1797	1470	1515	1470
q20	2066	1806	1832	1806
q21	5697	5454	5500	5454
q22	1109	1031	992	992
Total cold run time: 74253 ms
Total hot run time: 60428 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 197592 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 4b240957448304ff7a54fd96fefd47abd35ff8aa, data reload: false

query1	1281	919	898	898
query2	6341	2006	1994	1994
query3	10813	4455	4322	4322
query4	61298	29262	23356	23356
query5	5286	461	445	445
query6	413	198	186	186
query7	5461	322	308	308
query8	310	239	231	231
query9	8589	2592	2581	2581
query10	483	267	259	259
query11	17773	15201	16130	15201
query12	162	105	102	102
query13	1430	436	439	436
query14	9992	7683	7263	7263
query15	199	183	183	183
query16	7303	503	438	438
query17	1175	591	592	591
query18	1877	331	318	318
query19	211	163	175	163
query20	116	116	110	110
query21	204	107	106	106
query22	4663	4521	4547	4521
query23	34447	35181	33979	33979
query24	6127	2963	2952	2952
query25	537	421	425	421
query26	657	171	174	171
query27	1729	367	385	367
query28	4169	2490	2423	2423
query29	665	446	439	439
query30	258	159	168	159
query31	996	829	821	821
query32	65	57	57	57
query33	405	274	294	274
query34	933	515	518	515
query35	898	748	721	721
query36	1111	955	960	955
query37	112	64	65	64
query38	4091	3960	3991	3960
query39	1518	1472	1655	1472
query40	203	102	99	99
query41	51	49	48	48
query42	116	103	99	99
query43	536	486	480	480
query44	1177	807	821	807
query45	188	169	165	165
query46	1186	734	748	734
query47	2055	1927	1952	1927
query48	478	395	415	395
query49	736	418	383	383
query50	824	433	423	423
query51	7412	7340	7329	7329
query52	108	86	87	86
query53	258	188	199	188
query54	569	463	465	463
query55	77	80	77	77
query56	258	273	249	249
query57	1291	1172	1164	1164
query58	227	208	222	208
query59	3298	3168	3157	3157
query60	287	255	267	255
query61	113	110	112	110
query62	821	699	657	657
query63	223	193	187	187
query64	1408	675	629	629
query65	3254	3159	3186	3159
query66	688	293	300	293
query67	15804	15493	15587	15493
query68	4238	574	563	563
query69	439	265	263	263
query70	1192	1142	1136	1136
query71	359	275	265	265
query72	6036	4044	3982	3982
query73	754	340	348	340
query74	9800	9062	9252	9062
query75	3366	2653	2646	2646
query76	1999	1045	1014	1014
query77	546	278	274	274
query78	10643	9707	9632	9632
query79	1800	590	592	590
query80	1377	437	442	437
query81	537	242	235	235
query82	1281	92	89	89
query83	267	156	142	142
query84	279	82	87	82
query85	1027	307	294	294
query86	367	290	307	290
query87	4376	4182	4219	4182
query88	3686	2396	2364	2364
query89	419	286	292	286
query90	2000	185	185	185
query91	185	151	148	148
query92	64	50	48	48
query93	2554	551	555	551
query94	790	289	285	285
query95	351	260	256	256
query96	619	283	279	279
query97	3299	3199	3184	3184
query98	209	243	188	188
query99	1591	1315	1274	1274
Total cold run time: 314194 ms
Total hot run time: 197592 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.07	0.03	0.03
query3	0.24	0.07	0.06
query4	1.62	0.10	0.10
query5	0.53	0.52	0.52
query6	1.13	0.74	0.72
query7	0.02	0.02	0.01
query8	0.04	0.03	0.03
query9	0.57	0.51	0.51
query10	0.56	0.56	0.59
query11	0.14	0.10	0.11
query12	0.14	0.11	0.11
query13	0.60	0.59	0.59
query14	2.81	2.74	2.76
query15	0.90	0.83	0.83
query16	0.38	0.40	0.39
query17	1.01	1.08	1.07
query18	0.24	0.22	0.22
query19	1.97	1.81	2.10
query20	0.01	0.02	0.01
query21	15.37	0.61	0.56
query22	2.17	2.18	2.30
query23	16.88	1.05	0.79
query24	3.20	1.03	1.11
query25	0.22	0.33	0.06
query26	0.33	0.15	0.14
query27	0.04	0.04	0.06
query28	10.24	0.50	0.52
query29	12.62	3.29	3.25
query30	0.25	0.06	0.06
query31	2.86	0.37	0.37
query32	3.25	0.47	0.46
query33	3.00	3.02	2.97
query34	16.78	4.50	4.51
query35	4.50	4.47	4.56
query36	0.66	0.49	0.49
query37	0.09	0.06	0.06
query38	0.05	0.04	0.03
query39	0.03	0.02	0.03
query40	0.18	0.13	0.12
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.03	0.04	0.03
Total cold run time: 105.88 s
Total hot run time: 32.62 s

@924060929 924060929 force-pushed the branch-3.0-50142 branch from a90a0d8 to 4b24095 Compare May 8, 2025 14:05
@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17569	6790	6557	6557
q2	2064	167	164	164
q3	10637	1068	1123	1068
q4	10544	734	739	734
q5	7746	2848	2796	2796
q6	216	136	132	132
q7	948	616	607	607
q8	9364	1946	1972	1946
q9	6482	6367	6427	6367
q10	7002	2280	2273	2273
q11	472	271	272	271
q12	403	220	215	215
q13	17768	2977	2974	2974
q14	231	208	206	206
q15	504	460	454	454
q16	648	583	586	583
q17	967	594	567	567
q18	7077	6451	6640	6451
q19	1392	1032	1073	1032
q20	468	214	201	201
q21	4018	3171	3181	3171
q22	1087	1028	1052	1028
Total cold run time: 107607 ms
Total hot run time: 39797 ms

----- Round 2, with runtime_filter_mode=off -----
q1	6568	6535	6527	6527
q2	336	241	240	240
q3	2896	2748	2802	2748
q4	2048	1718	1758	1718
q5	5787	5753	5714	5714
q6	217	136	131	131
q7	2199	1836	1815	1815
q8	3350	3561	3488	3488
q9	8910	8747	8816	8747
q10	3549	3521	3524	3521
q11	599	484	494	484
q12	819	619	610	610
q13	8770	3187	3228	3187
q14	310	266	269	266
q15	500	483	482	482
q16	703	660	657	657
q17	1851	1605	1608	1605
q18	8135	7735	7678	7678
q19	1685	1500	1607	1500
q20	2102	1848	1843	1843
q21	5443	5511	5296	5296
q22	1119	1058	1048	1048
Total cold run time: 67896 ms
Total hot run time: 59305 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 196822 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 4b240957448304ff7a54fd96fefd47abd35ff8aa, data reload: false

query1	1286	914	907	907
query2	6361	2010	1981	1981
query3	10817	4333	4141	4141
query4	61255	28991	23645	23645
query5	5181	480	436	436
query6	404	177	179	177
query7	5510	326	301	301
query8	315	227	228	227
query9	8545	2599	2581	2581
query10	462	268	266	266
query11	17574	15130	15730	15130
query12	171	108	106	106
query13	1467	456	418	418
query14	10388	7218	7155	7155
query15	199	183	179	179
query16	7007	484	473	473
query17	1152	586	613	586
query18	1838	326	321	321
query19	222	167	167	167
query20	115	111	109	109
query21	215	104	113	104
query22	4719	4358	4734	4358
query23	34549	33937	34226	33937
query24	6115	2986	2896	2896
query25	549	420	424	420
query26	662	168	168	168
query27	2030	364	362	362
query28	4424	2430	2427	2427
query29	736	462	434	434
query30	240	165	160	160
query31	968	831	868	831
query32	65	59	58	58
query33	394	288	279	279
query34	905	510	505	505
query35	863	724	732	724
query36	1045	939	947	939
query37	114	67	68	67
query38	4054	3974	4003	3974
query39	1506	1490	1443	1443
query40	207	100	97	97
query41	48	49	47	47
query42	110	101	101	101
query43	536	479	470	470
query44	1166	808	823	808
query45	202	173	169	169
query46	1160	732	721	721
query47	2004	1902	1913	1902
query48	466	385	380	380
query49	738	394	390	390
query50	846	447	419	419
query51	7487	7123	7283	7123
query52	107	88	95	88
query53	261	184	186	184
query54	584	458	473	458
query55	76	75	79	75
query56	271	263	252	252
query57	1269	1189	1151	1151
query58	224	210	235	210
query59	3292	3059	2928	2928
query60	291	267	274	267
query61	118	117	112	112
query62	790	689	725	689
query63	225	192	197	192
query64	1410	689	651	651
query65	3352	3273	3185	3185
query66	705	306	301	301
query67	15932	15580	15421	15421
query68	4320	572	562	562
query69	432	269	265	265
query70	1161	1063	1146	1063
query71	353	266	244	244
query72	6350	4046	4058	4046
query73	746	350	363	350
query74	10086	9150	9184	9150
query75	3332	2663	2650	2650
query76	1984	1006	1039	1006
query77	516	278	281	278
query78	10626	9685	9608	9608
query79	1617	594	597	594
query80	884	438	421	421
query81	510	245	237	237
query82	1287	100	92	92
query83	245	148	140	140
query84	311	83	77	77
query85	860	294	296	294
query86	331	296	300	296
query87	4365	4247	4250	4247
query88	3813	2406	2328	2328
query89	416	287	286	286
query90	1993	185	188	185
query91	180	148	149	148
query92	66	50	54	50
query93	1970	561	551	551
query94	756	303	290	290
query95	353	264	254	254
query96	616	291	280	280
query97	3295	3180	3148	3148
query98	226	206	205	205
query99	1562	1294	1322	1294
Total cold run time: 313861 ms
Total hot run time: 196822 ms

@doris-robot
Copy link

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

query1	0.03	0.03	0.03
query2	0.06	0.04	0.03
query3	0.24	0.06	0.06
query4	1.63	0.10	0.10
query5	0.50	0.49	0.52
query6	1.14	0.75	0.72
query7	0.02	0.01	0.01
query8	0.05	0.03	0.03
query9	0.57	0.51	0.50
query10	0.56	0.55	0.53
query11	0.14	0.09	0.10
query12	0.15	0.12	0.12
query13	0.61	0.60	0.60
query14	2.86	2.79	2.78
query15	0.91	0.82	0.83
query16	0.39	0.38	0.36
query17	1.03	1.06	1.01
query18	0.24	0.22	0.22
query19	1.86	1.86	2.06
query20	0.01	0.01	0.01
query21	15.35	0.60	0.58
query22	2.74	2.16	2.03
query23	16.90	0.98	0.86
query24	3.42	1.70	0.86
query25	0.31	0.18	0.12
query26	0.36	0.15	0.14
query27	0.04	0.03	0.04
query28	9.76	0.55	0.53
query29	12.92	3.24	3.25
query30	0.25	0.06	0.06
query31	2.87	0.39	0.39
query32	3.23	0.48	0.46
query33	2.97	3.01	3.02
query34	17.01	4.50	4.56
query35	4.51	4.52	4.50
query36	0.69	0.50	0.48
query37	0.08	0.06	0.06
query38	0.04	0.03	0.03
query39	0.03	0.02	0.02
query40	0.18	0.12	0.13
query41	0.08	0.02	0.03
query42	0.04	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 106.81 s
Total hot run time: 32.46 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 bec367b into apache:branch-3.0 May 13, 2025
34 of 35 checks passed
@924060929 924060929 deleted the branch-3.0-50142 branch May 13, 2025 14:32
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