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

[fix](Nereids) fix double literal to string literal cast problem #49416

Merged
merged 5 commits into from
Mar 26, 2025

Conversation

LiBinfeng-01
Copy link
Collaborator

@LiBinfeng-01 LiBinfeng-01 commented Mar 24, 2025

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

When cast double like 1.000 to string, it should strip .000 in the trailing of double

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
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?

@morrySnow morrySnow added usercase Important user case type label dev/2.1.x dev/3.0.x labels Mar 24, 2025
@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	26148	5072	5026	5026
q2	2056	287	176	176
q3	10395	1201	660	660
q4	10238	1007	529	529
q5	7531	2308	2338	2308
q6	185	166	132	132
q7	905	750	602	602
q8	9549	1286	1077	1077
q9	6915	5182	5346	5182
q10	6803	2310	1902	1902
q11	475	276	269	269
q12	343	348	214	214
q13	17773	3664	3056	3056
q14	223	233	212	212
q15	536	469	493	469
q16	634	626	565	565
q17	567	839	340	340
q18	7604	7230	7171	7171
q19	1231	939	558	558
q20	312	316	192	192
q21	3952	2663	2455	2455
q22	1061	1024	969	969
Total cold run time: 115436 ms
Total hot run time: 34064 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5112	5116	5058	5058
q2	236	322	233	233
q3	2089	2655	2294	2294
q4	1406	1799	1380	1380
q5	4517	4402	4372	4372
q6	213	169	129	129
q7	2020	1900	1746	1746
q8	2622	2540	2503	2503
q9	7308	7233	6941	6941
q10	3053	3187	2736	2736
q11	569	506	484	484
q12	701	757	607	607
q13	3478	3873	3293	3293
q14	275	288	264	264
q15	517	476	475	475
q16	647	680	628	628
q17	1131	1526	1401	1401
q18	7725	7567	7524	7524
q19	782	829	779	779
q20	2021	2007	1822	1822
q21	5231	4953	4861	4861
q22	1068	1069	1026	1026
Total cold run time: 52721 ms
Total hot run time: 50556 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 193493 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 3c19f9ca6db047c4b6735268d7df6a00e198de8a, data reload: false

query1	1401	1055	1050	1050
query2	6400	1982	1936	1936
query3	11020	4425	4609	4425
query4	25691	23289	23036	23036
query5	3434	637	461	461
query6	300	209	197	197
query7	3985	475	269	269
query8	304	257	241	241
query9	8473	2585	2581	2581
query10	444	350	252	252
query11	15656	15119	14824	14824
query12	171	110	111	110
query13	1652	516	383	383
query14	9816	5999	6102	5999
query15	201	187	175	175
query16	7598	590	475	475
query17	1279	689	588	588
query18	2032	437	300	300
query19	198	194	165	165
query20	132	127	121	121
query21	206	131	110	110
query22	4739	4835	4500	4500
query23	34462	33734	33413	33413
query24	8370	2422	2404	2404
query25	515	457	414	414
query26	735	276	146	146
query27	2727	507	333	333
query28	4665	2483	2419	2419
query29	615	568	436	436
query30	286	229	185	185
query31	911	879	783	783
query32	73	58	64	58
query33	525	371	306	306
query34	770	868	506	506
query35	837	877	785	785
query36	1002	1026	925	925
query37	115	104	76	76
query38	4184	4143	4209	4143
query39	1495	1446	1452	1446
query40	210	124	104	104
query41	55	54	52	52
query42	124	106	108	106
query43	494	532	526	526
query44	1331	804	793	793
query45	181	172	170	170
query46	869	1024	655	655
query47	1885	1902	1814	1814
query48	379	421	305	305
query49	708	530	423	423
query50	720	770	421	421
query51	4306	4356	4290	4290
query52	108	101	101	101
query53	229	255	189	189
query54	489	507	410	410
query55	91	75	79	75
query56	297	271	263	263
query57	1208	1227	1134	1134
query58	276	239	250	239
query59	2818	2816	2914	2816
query60	305	297	289	289
query61	152	155	178	155
query62	766	759	668	668
query63	230	184	184	184
query64	3007	1043	697	697
query65	4579	4487	4475	4475
query66	804	402	294	294
query67	16432	15811	15593	15593
query68	8432	873	514	514
query69	472	296	263	263
query70	1201	1119	1080	1080
query71	461	305	279	279
query72	5408	5280	5013	5013
query73	676	571	348	348
query74	8920	9071	8985	8985
query75	3927	3231	2704	2704
query76	3614	1174	754	754
query77	785	371	287	287
query78	10079	10100	9404	9404
query79	2209	777	569	569
query80	622	520	442	442
query81	482	262	228	228
query82	475	129	92	92
query83	177	258	152	152
query84	243	90	77	77
query85	775	355	316	316
query86	375	315	284	284
query87	4413	4530	4375	4375
query88	3588	2186	2205	2186
query89	405	332	272	272
query90	1774	209	206	206
query91	142	139	170	139
query92	75	59	56	56
query93	1827	1067	578	578
query94	639	405	300	300
query95	354	269	260	260
query96	479	557	275	275
query97	3334	3403	3359	3359
query98	237	206	200	200
query99	1429	1378	1279	1279
Total cold run time: 278501 ms
Total hot run time: 193493 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.12	0.11	0.10
query3	0.25	0.19	0.19
query4	1.59	0.18	0.18
query5	0.60	0.56	0.59
query6	1.20	0.71	0.71
query7	0.02	0.02	0.02
query8	0.04	0.04	0.03
query9	0.57	0.52	0.51
query10	0.56	0.60	0.56
query11	0.15	0.10	0.11
query12	0.15	0.11	0.11
query13	0.62	0.60	0.60
query14	2.66	2.75	2.70
query15	0.92	0.84	0.84
query16	0.39	0.38	0.37
query17	1.01	1.03	1.00
query18	0.21	0.19	0.19
query19	1.90	1.90	1.88
query20	0.01	0.02	0.01
query21	15.36	0.90	0.54
query22	0.76	1.18	0.63
query23	14.95	1.29	0.60
query24	7.31	1.09	0.77
query25	0.46	0.20	0.14
query26	0.60	0.16	0.15
query27	0.05	0.04	0.04
query28	9.84	0.88	0.43
query29	12.52	3.99	3.30
query30	0.25	0.09	0.06
query31	2.83	0.59	0.38
query32	3.23	0.55	0.47
query33	3.04	3.10	3.13
query34	15.90	5.10	4.51
query35	4.55	4.49	4.51
query36	0.65	0.50	0.48
query37	0.08	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.02	0.02
query40	0.17	0.13	0.12
query41	0.08	0.03	0.03
query42	0.04	0.03	0.02
query43	0.04	0.03	0.03
Total cold run time: 105.81 s
Total hot run time: 31.1 s

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	25902	5235	5225	5225
q2	2079	305	164	164
q3	10403	1328	693	693
q4	10224	1079	534	534
q5	7542	2467	2486	2467
q6	206	170	131	131
q7	963	754	602	602
q8	9326	1500	1313	1313
q9	6784	5318	5329	5318
q10	6865	2356	1907	1907
q11	501	288	247	247
q12	355	383	216	216
q13	17766	3774	3128	3128
q14	237	235	214	214
q15	555	498	499	498
q16	619	618	596	596
q17	617	934	363	363
q18	7761	7277	7197	7197
q19	1578	1111	609	609
q20	327	342	195	195
q21	4046	3427	2566	2566
q22	1056	1042	952	952
Total cold run time: 115712 ms
Total hot run time: 35135 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5519	5416	5449	5416
q2	244	335	227	227
q3	2203	2724	2318	2318
q4	1645	1990	1479	1479
q5	4583	4407	4330	4330
q6	245	176	128	128
q7	2046	1898	1735	1735
q8	2772	2752	2726	2726
q9	7155	7163	7143	7143
q10	3001	3178	2767	2767
q11	590	518	501	501
q12	694	763	618	618
q13	3587	3968	3318	3318
q14	289	288	276	276
q15	557	510	489	489
q16	639	693	641	641
q17	1214	1708	1398	1398
q18	7630	7516	7451	7451
q19	838	827	928	827
q20	1929	1966	1819	1819
q21	5433	4789	4712	4712
q22	1083	1038	988	988
Total cold run time: 53896 ms
Total hot run time: 51307 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 186698 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 3edb2a3acea79f7893bd35ca0bc18c917f4c9e53, data reload: false

query1	1006	471	460	460
query2	6541	2015	1928	1928
query3	6810	224	233	224
query4	26017	23595	23022	23022
query5	4285	657	483	483
query6	297	189	208	189
query7	4598	470	261	261
query8	289	245	230	230
query9	8590	2579	2564	2564
query10	443	336	289	289
query11	15695	15574	14846	14846
query12	169	112	107	107
query13	1645	513	379	379
query14	9599	6120	6131	6120
query15	205	193	168	168
query16	7627	622	507	507
query17	1216	720	588	588
query18	2033	408	319	319
query19	191	189	159	159
query20	120	115	113	113
query21	212	126	104	104
query22	4328	4333	4346	4333
query23	33979	33107	33035	33035
query24	8497	2357	2375	2357
query25	556	493	419	419
query26	1239	271	146	146
query27	2751	507	322	322
query28	4401	2396	2408	2396
query29	734	555	425	425
query30	284	218	192	192
query31	976	821	763	763
query32	71	65	65	65
query33	556	383	310	310
query34	765	921	489	489
query35	797	815	728	728
query36	933	966	906	906
query37	126	95	79	79
query38	4307	4110	4102	4102
query39	1454	1391	1401	1391
query40	210	117	102	102
query41	57	55	58	55
query42	123	103	103	103
query43	503	488	530	488
query44	1281	809	791	791
query45	173	169	174	169
query46	830	1027	611	611
query47	1792	1824	1786	1786
query48	375	407	313	313
query49	759	493	428	428
query50	687	728	394	394
query51	4187	4150	4125	4125
query52	111	108	99	99
query53	221	237	177	177
query54	474	489	442	442
query55	90	83	80	80
query56	279	276	261	261
query57	1143	1164	1083	1083
query58	246	256	234	234
query59	2749	2788	2812	2788
query60	287	281	271	271
query61	127	126	124	124
query62	792	757	651	651
query63	211	182	176	176
query64	4290	1015	678	678
query65	4525	4321	4365	4321
query66	1059	413	286	286
query67	15933	15592	15347	15347
query68	8055	877	489	489
query69	456	288	262	262
query70	1191	1098	1110	1098
query71	454	285	260	260
query72	5296	4998	4923	4923
query73	680	555	340	340
query74	8863	9147	8705	8705
query75	3852	3205	2691	2691
query76	3682	1184	735	735
query77	780	360	279	279
query78	9896	10261	9391	9391
query79	1927	806	545	545
query80	646	526	454	454
query81	461	258	223	223
query82	436	136	100	100
query83	185	175	157	157
query84	238	92	76	76
query85	774	356	319	319
query86	335	305	301	301
query87	4382	4494	4271	4271
query88	3536	2238	2264	2238
query89	380	307	280	280
query90	1948	208	210	208
query91	141	144	110	110
query92	82	61	63	61
query93	1435	1042	573	573
query94	672	417	323	323
query95	368	283	267	267
query96	489	566	282	282
query97	3390	3349	3331	3331
query98	233	205	205	205
query99	1421	1409	1300	1300
Total cold run time: 274540 ms
Total hot run time: 186698 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.12	0.10	0.11
query3	0.25	0.19	0.20
query4	1.60	0.19	0.20
query5	0.60	0.58	0.61
query6	1.17	0.71	0.73
query7	0.02	0.02	0.01
query8	0.04	0.03	0.03
query9	0.58	0.52	0.54
query10	0.57	0.60	0.57
query11	0.16	0.11	0.11
query12	0.14	0.11	0.12
query13	0.62	0.60	0.62
query14	2.79	2.72	2.70
query15	0.91	0.84	0.85
query16	0.38	0.38	0.36
query17	1.02	1.06	1.03
query18	0.21	0.19	0.19
query19	1.93	1.92	1.83
query20	0.01	0.01	0.02
query21	15.39	0.92	0.53
query22	0.75	1.22	0.70
query23	14.87	1.38	0.56
query24	7.03	1.05	0.51
query25	0.53	0.22	0.17
query26	0.65	0.15	0.13
query27	0.05	0.04	0.06
query28	9.25	0.92	0.42
query29	12.54	3.98	3.36
query30	0.25	0.08	0.06
query31	2.84	0.58	0.38
query32	3.22	0.55	0.47
query33	2.99	3.02	3.05
query34	15.83	5.10	4.52
query35	4.50	4.55	4.49
query36	0.67	0.49	0.48
query37	0.09	0.06	0.06
query38	0.06	0.04	0.03
query39	0.03	0.02	0.03
query40	0.17	0.13	0.13
query41	0.09	0.03	0.03
query42	0.04	0.03	0.02
query43	0.04	0.03	0.04
Total cold run time: 105.04 s
Total hot run time: 30.87 s

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	25771	5019	4980	4980
q2	2056	305	159	159
q3	10397	1224	669	669
q4	10224	995	516	516
q5	7547	2354	2322	2322
q6	180	163	134	134
q7	908	726	604	604
q8	9310	1251	1125	1125
q9	6881	5095	5146	5095
q10	6800	2315	1915	1915
q11	480	274	266	266
q12	349	360	222	222
q13	17771	3613	3011	3011
q14	231	228	218	218
q15	541	484	478	478
q16	642	612	576	576
q17	572	846	326	326
q18	7536	7073	7101	7073
q19	1562	958	543	543
q20	306	308	189	189
q21	3888	3391	2438	2438
q22	1050	1033	1009	1009
Total cold run time: 115002 ms
Total hot run time: 33868 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5181	5125	5048	5048
q2	249	341	235	235
q3	2210	2703	2332	2332
q4	1422	1834	1428	1428
q5	4470	4468	4388	4388
q6	210	171	132	132
q7	2003	1923	1777	1777
q8	2582	2610	2522	2522
q9	7305	7183	7120	7120
q10	2973	3189	2736	2736
q11	569	521	521	521
q12	691	766	630	630
q13	3513	3906	3286	3286
q14	299	294	265	265
q15	554	500	495	495
q16	646	680	692	680
q17	1141	1583	1367	1367
q18	7815	7510	7420	7420
q19	780	802	894	802
q20	1909	1943	1821	1821
q21	5244	4904	4713	4713
q22	1087	1079	1039	1039
Total cold run time: 52853 ms
Total hot run time: 50757 ms

@doris-robot
Copy link

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

query1	1390	1033	1037	1033
query2	6362	1922	1899	1899
query3	10983	4555	4427	4427
query4	53808	25121	23309	23309
query5	5126	561	483	483
query6	348	212	190	190
query7	5000	497	265	265
query8	320	257	258	257
query9	6153	2578	2589	2578
query10	422	309	247	247
query11	15109	15105	14953	14953
query12	166	110	106	106
query13	1133	493	378	378
query14	10033	6423	6287	6287
query15	204	189	179	179
query16	6954	691	489	489
query17	1033	726	561	561
query18	1534	409	318	318
query19	191	193	162	162
query20	135	125	126	125
query21	211	126	107	107
query22	4298	4649	4362	4362
query23	34040	33491	33556	33491
query24	6682	2451	2483	2451
query25	501	506	443	443
query26	724	280	154	154
query27	2724	512	339	339
query28	3299	2446	2461	2446
query29	618	565	423	423
query30	268	228	190	190
query31	843	864	837	837
query32	80	65	62	62
query33	436	353	308	308
query34	766	856	515	515
query35	825	863	760	760
query36	944	1026	928	928
query37	123	102	86	86
query38	4228	4196	4118	4118
query39	1475	1475	1438	1438
query40	211	118	105	105
query41	56	55	51	51
query42	123	106	106	106
query43	494	515	486	486
query44	1312	832	819	819
query45	182	182	177	177
query46	852	1029	636	636
query47	1917	1911	1845	1845
query48	399	415	312	312
query49	703	550	484	484
query50	703	753	415	415
query51	4249	4298	4236	4236
query52	108	110	101	101
query53	233	262	181	181
query54	492	490	429	429
query55	83	93	88	88
query56	269	284	260	260
query57	1183	1213	1150	1150
query58	248	250	233	233
query59	2679	2808	2637	2637
query60	283	271	256	256
query61	146	129	127	127
query62	727	757	723	723
query63	226	186	190	186
query64	1645	1097	686	686
query65	4431	4405	4396	4396
query66	721	391	287	287
query67	16003	15641	15368	15368
query68	7522	821	498	498
query69	533	299	258	258
query70	1180	1113	1081	1081
query71	483	290	274	274
query72	5785	4841	4986	4841
query73	1213	699	348	348
query74	8961	9328	8952	8952
query75	3417	3205	2734	2734
query76	3894	1200	739	739
query77	552	372	278	278
query78	9924	10189	9335	9335
query79	2008	819	572	572
query80	594	514	453	453
query81	494	252	222	222
query82	452	127	107	107
query83	181	175	165	165
query84	284	95	76	76
query85	762	365	306	306
query86	374	294	296	294
query87	4399	4554	4377	4377
query88	3677	2280	2221	2221
query89	397	314	275	275
query90	1777	220	216	216
query91	149	144	111	111
query92	72	60	59	59
query93	1704	1051	576	576
query94	726	418	310	310
query95	357	276	267	267
query96	482	569	276	276
query97	3141	3240	3131	3131
query98	226	207	197	197
query99	1564	1405	1279	1279
Total cold run time: 297451 ms
Total hot run time: 193312 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.12	0.11	0.11
query3	0.24	0.20	0.19
query4	1.59	0.20	0.11
query5	0.56	0.55	0.56
query6	1.20	0.72	0.72
query7	0.03	0.02	0.02
query8	0.04	0.03	0.03
query9	0.57	0.52	0.52
query10	0.58	0.61	0.56
query11	0.16	0.11	0.11
query12	0.15	0.11	0.12
query13	0.61	0.60	0.60
query14	2.79	2.70	2.82
query15	0.92	0.85	0.85
query16	0.38	0.38	0.39
query17	1.07	1.03	1.00
query18	0.20	0.20	0.19
query19	2.01	1.82	1.76
query20	0.01	0.01	0.01
query21	15.73	0.92	0.56
query22	0.87	1.17	0.70
query23	15.08	1.38	0.61
query24	6.92	1.44	1.33
query25	0.47	0.20	0.15
query26	0.56	0.16	0.13
query27	0.06	0.05	0.04
query28	9.23	0.89	0.43
query29	12.58	3.96	3.29
query30	0.24	0.09	0.07
query31	2.83	0.59	0.37
query32	3.22	0.54	0.49
query33	3.09	2.99	3.08
query34	15.66	5.08	4.50
query35	4.49	4.51	4.53
query36	0.66	0.49	0.48
query37	0.08	0.06	0.06
query38	0.05	0.04	0.03
query39	0.02	0.02	0.02
query40	0.16	0.13	0.13
query41	0.08	0.03	0.02
query42	0.03	0.02	0.03
query43	0.04	0.03	0.03
Total cold run time: 105.42 s
Total hot run time: 31.51 s

morrySnow
morrySnow previously approved these changes Mar 25, 2025
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Mar 25, 2025
Copy link
Contributor

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

Copy link
Contributor

PR approved by anyone and no changes requested.

Comment on lines 265 to 271
return new VarcharLiteral(desc.replaceAll("\\.0+$", ""), ((VarcharType) targetType).getLen());
}
return new VarcharLiteral(desc, ((VarcharType) targetType).getLen());
} else if (targetType instanceof StringType) {
if (this.dataType.isDoubleType() || this.dataType.isFloatType()) {
return new StringLiteral(desc.replaceAll("\\.0+$", ""));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't use replace regex because of low performance.

I think you should optimize the code like this:

private static int findPointZeroIndex(String str) {
    int pointIndex = -1;
    for (int i = 0; i < str.length(); ++i) {
        char c = str.charAt(i);
        if (pointIndex > 0 && c != '0') {
            return -1;
        } else if (pointIndex == -1 && c == '.') {
            pointIndex = i;
        }
    }
    return pointIndex;
}

int pointZeroIndex = findPointZeroIndex(desc);
if (pointZeroIndex > -1) {
    return new VarcharLiteral(desc.substring(0, pointZeroIndex), ((VarcharType) targetType).getLen());
} else {
    return new VarcharLiteral(desc, ((VarcharType) targetType).getLen());
}

@924060929
Copy link
Contributor

924060929 commented Mar 26, 2025

does backend have different behavior to your fix? @LiBinfeng-01

for example:

set debug_skip_fold_constant=true;
select cast(1.00000 as varchar(4));

the backend return the result 1.00

but your fix will replace 1.00000 to 1

@LiBinfeng-01
Copy link
Collaborator Author

does backend have different behavior to your fix? @LiBinfeng-01

for example:

set debug_skip_fold_constant=true;
select cast(1.00000 as varchar(4));

the backend return the result 1.00

but your fix will replace 1.00000 to 1

fe and be have same behavior:

mysql> select cast(cast (1.00000 as double) as varchar(4));
+----------------------------------------------+
| cast(cast (1.00000 as double) as varchar(4)) |
+----------------------------------------------+
| 1                                            |
+----------------------------------------------+
1 row in set (0.00 sec)

mysql> set debug_skip_fold_constant=true;
Query OK, 0 rows affected (0.00 sec)

mysql> select cast(cast (1.00000 as double) as varchar(4));
+----------------------------------------------+
| cast(cast (1.00000 as double) as varchar(4)) |
+----------------------------------------------+
| 1                                            |
+----------------------------------------------+
1 row in set (0.03 sec)

@LiBinfeng-01
Copy link
Collaborator Author

run buildall

@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Mar 26, 2025
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	25999	5090	5032	5032
q2	2066	318	178	178
q3	10388	1263	694	694
q4	10225	1024	520	520
q5	8044	2779	2374	2374
q6	194	164	131	131
q7	940	751	620	620
q8	9327	1303	1120	1120
q9	6917	5165	5153	5153
q10	6865	2327	1903	1903
q11	480	271	265	265
q12	352	366	223	223
q13	17789	3743	3088	3088
q14	231	226	221	221
q15	538	492	487	487
q16	625	606	586	586
q17	604	871	350	350
q18	7829	7343	7153	7153
q19	1948	984	567	567
q20	325	336	194	194
q21	3964	3404	2449	2449
q22	1114	1034	970	970
Total cold run time: 116764 ms
Total hot run time: 34278 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5273	5125	5183	5125
q2	237	327	231	231
q3	2159	2695	2338	2338
q4	1429	1913	1492	1492
q5	4508	4411	4417	4411
q6	222	172	126	126
q7	1997	1957	1796	1796
q8	2607	2609	2534	2534
q9	7350	7112	7220	7112
q10	3026	3179	2766	2766
q11	594	514	500	500
q12	709	780	632	632
q13	3502	3916	3380	3380
q14	287	289	267	267
q15	535	485	476	476
q16	648	713	663	663
q17	1167	1566	1390	1390
q18	7744	7747	7519	7519
q19	791	792	916	792
q20	1938	1978	1853	1853
q21	5478	4959	4847	4847
q22	1127	1075	1032	1032
Total cold run time: 53328 ms
Total hot run time: 51282 ms

@doris-robot
Copy link

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

query1	1404	1051	1069	1051
query2	6287	1940	1888	1888
query3	11185	4718	4581	4581
query4	25643	23596	23150	23150
query5	3623	645	491	491
query6	306	202	187	187
query7	3975	504	275	275
query8	296	243	228	228
query9	8510	2609	2590	2590
query10	469	309	253	253
query11	15548	15103	14857	14857
query12	159	111	114	111
query13	1576	547	402	402
query14	8522	6246	6172	6172
query15	205	188	175	175
query16	7229	616	447	447
query17	1214	704	554	554
query18	2023	411	315	315
query19	198	192	164	164
query20	133	120	125	120
query21	209	156	111	111
query22	4655	4719	4637	4637
query23	34376	33675	33705	33675
query24	8674	2452	2456	2452
query25	539	476	390	390
query26	1212	277	146	146
query27	2880	501	344	344
query28	4752	2445	2431	2431
query29	755	570	433	433
query30	286	227	191	191
query31	908	841	803	803
query32	77	63	65	63
query33	539	369	346	346
query34	790	882	513	513
query35	830	848	800	800
query36	989	1025	931	931
query37	128	105	92	92
query38	4225	4234	4267	4234
query39	1490	1464	1479	1464
query40	204	117	114	114
query41	53	53	49	49
query42	130	102	109	102
query43	497	512	499	499
query44	1308	807	799	799
query45	179	171	165	165
query46	852	1040	660	660
query47	1891	1946	1851	1851
query48	380	419	313	313
query49	790	525	427	427
query50	684	752	437	437
query51	4383	4230	4286	4230
query52	103	101	97	97
query53	225	268	183	183
query54	507	519	423	423
query55	81	81	80	80
query56	289	271	265	265
query57	1179	1232	1134	1134
query58	249	238	247	238
query59	2659	2790	2823	2790
query60	287	299	281	281
query61	133	143	127	127
query62	759	750	672	672
query63	229	189	182	182
query64	4153	1048	699	699
query65	4465	4594	4346	4346
query66	1174	431	329	329
query67	16607	15637	15524	15524
query68	9723	841	510	510
query69	482	303	268	268
query70	1152	1135	1101	1101
query71	459	295	256	256
query72	5161	4623	4881	4623
query73	703	572	341	341
query74	9248	8824	8738	8738
query75	4323	3240	2774	2774
query76	4169	1187	743	743
query77	932	361	285	285
query78	9917	10341	9405	9405
query79	1826	796	569	569
query80	707	552	452	452
query81	487	264	227	227
query82	259	126	97	97
query83	227	178	160	160
query84	278	91	74	74
query85	750	350	317	317
query86	332	303	280	280
query87	4391	4602	4267	4267
query88	2805	2217	2206	2206
query89	400	300	280	280
query90	1976	207	210	207
query91	146	140	112	112
query92	81	60	56	56
query93	1479	1033	589	589
query94	645	430	310	310
query95	359	269	267	267
query96	497	568	278	278
query97	3152	3263	3115	3115
query98	244	221	205	205
query99	1387	1409	1272	1272
Total cold run time: 279966 ms
Total hot run time: 193467 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.12	0.10	0.11
query3	0.26	0.20	0.19
query4	1.59	0.19	0.20
query5	0.60	0.61	0.58
query6	1.20	0.73	0.72
query7	0.02	0.02	0.02
query8	0.04	0.03	0.03
query9	0.58	0.52	0.52
query10	0.59	0.60	0.57
query11	0.17	0.11	0.11
query12	0.15	0.11	0.12
query13	0.62	0.60	0.61
query14	2.81	2.68	2.81
query15	0.94	0.86	0.84
query16	0.40	0.37	0.38
query17	1.03	1.02	1.03
query18	0.21	0.20	0.19
query19	1.91	2.00	1.86
query20	0.01	0.01	0.01
query21	15.35	0.92	0.55
query22	0.77	1.18	0.76
query23	14.82	1.36	0.61
query24	7.38	1.50	0.38
query25	0.47	0.17	0.12
query26	0.66	0.17	0.12
query27	0.06	0.05	0.05
query28	8.40	0.84	0.42
query29	12.54	4.09	3.42
query30	0.24	0.09	0.06
query31	2.84	0.59	0.39
query32	3.24	0.56	0.47
query33	2.99	3.13	3.03
query34	15.86	5.12	4.52
query35	4.60	4.52	4.51
query36	0.65	0.49	0.49
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.02	0.02
query40	0.18	0.13	0.13
query41	0.08	0.03	0.03
query42	0.04	0.02	0.02
query43	0.04	0.03	0.04
Total cold run time: 104.68 s
Total hot run time: 30.96 s

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Mar 26, 2025
Copy link
Contributor

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

@morrySnow morrySnow merged commit 58393b6 into apache:master Mar 26, 2025
25 of 27 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 26, 2025
)

When cast double like 1.000 to string, it should strip .000 in the
trailing of double
github-actions bot pushed a commit that referenced this pull request Mar 26, 2025
)

When cast double like 1.000 to string, it should strip .000 in the
trailing of double
dataroaring pushed a commit that referenced this pull request Mar 27, 2025
yiguolei pushed a commit that referenced this pull request Mar 28, 2025
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.x dev/3.0.5-merged reviewed usercase Important user case type label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants