Skip to content

Conversation

@zclllyybb
Copy link
Contributor

@zclllyybb zclllyybb commented Mar 25, 2025

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

should consider the microseconds' effect.

before:

mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         24 |
+------------------------------------------------------------+

now:

mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         23 |
+------------------------------------------------------------+

Release note

fix the wrong floor of function date_diff when unit less than day

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?

@zclllyybb
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	26378	5080	5049	5049
q2	2062	288	161	161
q3	10427	1275	697	697
q4	10232	1046	562	562
q5	7553	2427	2355	2355
q6	191	164	135	135
q7	909	751	626	626
q8	9351	1347	1166	1166
q9	6827	5139	5144	5139
q10	6866	2301	1891	1891
q11	497	277	253	253
q12	351	351	215	215
q13	17772	3689	3111	3111
q14	250	234	220	220
q15	534	489	494	489
q16	628	609	574	574
q17	615	864	346	346
q18	7821	7234	7239	7234
q19	1709	967	574	574
q20	316	321	199	199
q21	4230	2748	2575	2575
q22	1069	1003	959	959
Total cold run time: 116588 ms
Total hot run time: 34530 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5229	5121	5139	5121
q2	234	326	226	226
q3	2168	2655	2311	2311
q4	1411	1845	1469	1469
q5	4509	4400	4413	4400
q6	215	170	131	131
q7	2004	1933	1791	1791
q8	2703	2619	2488	2488
q9	7290	7191	7200	7191
q10	3000	3193	2754	2754
q11	580	505	480	480
q12	716	730	619	619
q13	3503	3934	3344	3344
q14	305	309	261	261
q15	549	491	484	484
q16	653	678	669	669
q17	1173	1581	1428	1428
q18	7757	7659	7421	7421
q19	849	842	991	842
q20	1958	1968	1862	1862
q21	5387	5044	4901	4901
q22	1107	1058	1001	1001
Total cold run time: 53300 ms
Total hot run time: 51194 ms

@doris-robot
Copy link

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

query1	1419	1053	1054	1053
query2	6096	1918	1917	1917
query3	11016	4597	4517	4517
query4	26002	23775	23029	23029
query5	4823	660	490	490
query6	317	205	196	196
query7	3985	490	276	276
query8	304	241	242	241
query9	8557	2585	2551	2551
query10	500	304	256	256
query11	15471	15205	14741	14741
query12	166	110	106	106
query13	1540	506	386	386
query14	9196	6140	6188	6140
query15	202	187	189	187
query16	7584	630	450	450
query17	1162	742	581	581
query18	2041	408	316	316
query19	187	183	161	161
query20	125	122	120	120
query21	204	129	117	117
query22	4322	4627	4517	4517
query23	34385	33496	33478	33478
query24	8440	2449	2409	2409
query25	532	485	415	415
query26	723	272	149	149
query27	2885	499	325	325
query28	4820	2466	2482	2466
query29	629	592	435	435
query30	277	219	194	194
query31	919	883	808	808
query32	75	72	62	62
query33	536	374	310	310
query34	836	869	502	502
query35	821	863	752	752
query36	970	1024	916	916
query37	123	103	81	81
query38	4245	4175	4047	4047
query39	1480	1471	1456	1456
query40	204	120	131	120
query41	57	54	52	52
query42	121	103	109	103
query43	496	524	476	476
query44	1320	827	815	815
query45	183	173	168	168
query46	854	1062	651	651
query47	1837	1875	1796	1796
query48	389	411	308	308
query49	711	531	427	427
query50	702	760	426	426
query51	4334	4307	4279	4279
query52	107	105	95	95
query53	235	257	187	187
query54	494	516	436	436
query55	85	85	84	84
query56	281	265	274	265
query57	1195	1183	1129	1129
query58	259	259	259	259
query59	2864	2853	2807	2807
query60	309	273	268	268
query61	130	137	123	123
query62	768	728	669	669
query63	227	185	190	185
query64	2928	1016	674	674
query65	4616	4486	4527	4486
query66	774	396	304	304
query67	16725	15728	15612	15612
query68	8443	879	501	501
query69	491	294	259	259
query70	1229	1150	1072	1072
query71	462	290	261	261
query72	5228	4965	4910	4910
query73	685	544	348	348
query74	9012	8870	8917	8870
query75	3944	3264	2731	2731
query76	3665	1187	746	746
query77	794	365	286	286
query78	9796	10052	9300	9300
query79	2929	792	561	561
query80	631	532	462	462
query81	466	264	224	224
query82	286	126	103	103
query83	185	179	173	173
query84	294	96	80	80
query85	923	439	308	308
query86	325	315	283	283
query87	4477	4424	4383	4383
query88	2821	2264	2232	2232
query89	412	311	284	284
query90	2145	209	210	209
query91	140	152	109	109
query92	70	56	54	54
query93	1937	1025	579	579
query94	679	406	305	305
query95	357	274	263	263
query96	495	565	274	274
query97	3243	3413	3293	3293
query98	220	216	200	200
query99	1391	1389	1271	1271
Total cold run time: 279295 ms
Total hot run time: 193291 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.12	0.10	0.11
query3	0.24	0.20	0.19
query4	1.60	0.18	0.20
query5	0.59	0.59	0.58
query6	1.19	0.72	0.71
query7	0.02	0.02	0.01
query8	0.04	0.04	0.03
query9	0.59	0.52	0.54
query10	0.56	0.59	0.55
query11	0.15	0.11	0.11
query12	0.15	0.11	0.12
query13	0.61	0.61	0.61
query14	2.69	2.83	2.78
query15	0.92	0.86	0.84
query16	0.38	0.38	0.38
query17	1.04	1.02	1.04
query18	0.21	0.19	0.19
query19	1.95	1.96	1.80
query20	0.01	0.02	0.01
query21	15.36	0.88	0.54
query22	0.76	1.15	0.70
query23	14.89	1.35	0.58
query24	7.98	0.71	0.32
query25	0.50	0.17	0.09
query26	0.63	0.17	0.14
query27	0.05	0.04	0.05
query28	9.06	0.90	0.44
query29	12.56	4.03	3.36
query30	0.25	0.09	0.07
query31	2.82	0.57	0.40
query32	3.23	0.55	0.46
query33	3.08	3.06	3.06
query34	15.77	5.05	4.44
query35	4.51	4.52	4.47
query36	0.65	0.49	0.49
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.03	0.03	0.02
query40	0.18	0.13	0.13
query41	0.08	0.03	0.02
query42	0.04	0.03	0.02
query43	0.03	0.03	0.03
Total cold run time: 105.7 s
Total hot run time: 30.67 s

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 64.00% (16/25) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 50.22% (13440/26760)
Line Coverage 39.67% (116423/293496)
Region Coverage 38.38% (59182/154189)
Branch Coverage 33.52% (29902/89206)

@zclllyybb
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	26328	5037	5029	5029
q2	2064	303	173	173
q3	10466	1287	725	725
q4	10230	1010	542	542
q5	7628	2436	2398	2398
q6	195	167	134	134
q7	930	768	626	626
q8	9323	1338	1265	1265
q9	6867	5127	5092	5092
q10	6844	2319	1905	1905
q11	483	284	263	263
q12	357	366	228	228
q13	17759	3671	3105	3105
q14	251	236	219	219
q15	532	483	482	482
q16	663	633	581	581
q17	582	873	343	343
q18	7769	7309	7150	7150
q19	1520	989	600	600
q20	333	345	192	192
q21	4255	2626	2401	2401
q22	1052	1036	989	989
Total cold run time: 116431 ms
Total hot run time: 34442 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5182	5111	5213	5111
q2	248	337	227	227
q3	2223	2679	2300	2300
q4	1443	1870	1449	1449
q5	4533	4446	4442	4442
q6	215	168	132	132
q7	2025	1973	1776	1776
q8	2665	2618	2568	2568
q9	7416	7155	7266	7155
q10	3027	3222	2773	2773
q11	588	508	509	508
q12	688	797	627	627
q13	3502	3927	3375	3375
q14	297	291	269	269
q15	526	466	466	466
q16	641	687	659	659
q17	1201	1585	1441	1441
q18	7929	7677	7470	7470
q19	891	862	965	862
q20	1931	1979	1827	1827
q21	5410	5011	4822	4822
q22	1136	1094	1051	1051
Total cold run time: 53717 ms
Total hot run time: 51310 ms

@doris-robot
Copy link

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

query1	1436	1063	1028	1028
query2	6198	1962	1950	1950
query3	11102	4519	4572	4519
query4	25999	23552	23200	23200
query5	4263	672	476	476
query6	311	226	195	195
query7	3987	490	278	278
query8	308	248	237	237
query9	8524	2569	2566	2566
query10	476	309	268	268
query11	15551	15299	14843	14843
query12	165	115	107	107
query13	1572	539	395	395
query14	9162	6308	6173	6173
query15	211	183	170	170
query16	7626	645	473	473
query17	1196	766	618	618
query18	2074	424	323	323
query19	201	193	163	163
query20	128	124	125	124
query21	207	123	108	108
query22	4665	4645	4364	4364
query23	34317	33891	33719	33719
query24	8647	2417	2451	2417
query25	528	474	390	390
query26	1258	277	147	147
query27	2883	495	328	328
query28	5014	2476	2452	2452
query29	718	606	451	451
query30	301	222	186	186
query31	914	858	820	820
query32	74	62	62	62
query33	535	365	303	303
query34	796	877	546	546
query35	815	857	745	745
query36	963	1027	918	918
query37	125	104	82	82
query38	4295	4231	4243	4231
query39	1504	1457	1478	1457
query40	213	116	100	100
query41	52	53	51	51
query42	125	107	107	107
query43	514	520	510	510
query44	1413	846	811	811
query45	185	182	174	174
query46	882	1061	652	652
query47	1876	1900	1811	1811
query48	382	426	306	306
query49	760	528	415	415
query50	710	751	412	412
query51	4327	4326	4265	4265
query52	105	104	100	100
query53	227	258	179	179
query54	506	516	419	419
query55	83	81	83	81
query56	286	278	271	271
query57	1143	1208	1129	1129
query58	255	244	255	244
query59	2799	2930	2784	2784
query60	292	288	259	259
query61	128	122	121	121
query62	775	757	691	691
query63	224	191	186	186
query64	4360	1031	747	747
query65	4477	4353	4407	4353
query66	1081	407	306	306
query67	16213	15751	15622	15622
query68	8550	892	500	500
query69	524	300	259	259
query70	1233	1100	1126	1100
query71	456	310	259	259
query72	5379	4796	4840	4796
query73	725	637	352	352
query74	8926	9248	9004	9004
query75	3986	3237	2736	2736
query76	3785	1202	777	777
query77	789	379	282	282
query78	10040	10236	9291	9291
query79	2473	805	572	572
query80	657	596	454	454
query81	474	256	218	218
query82	466	127	95	95
query83	208	185	160	160
query84	286	98	71	71
query85	781	345	307	307
query86	335	299	298	298
query87	4437	4467	4352	4352
query88	3395	2276	2204	2204
query89	400	312	287	287
query90	1920	212	217	212
query91	146	146	110	110
query92	73	64	59	59
query93	1650	1055	577	577
query94	666	421	300	300
query95	382	276	264	264
query96	481	556	276	276
query97	3215	3248	3159	3159
query98	220	204	205	204
query99	1452	1428	1285	1285
Total cold run time: 281952 ms
Total hot run time: 193758 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.12	0.11	0.10
query3	0.24	0.19	0.19
query4	1.60	0.19	0.18
query5	0.61	0.59	0.60
query6	1.19	0.72	0.73
query7	0.02	0.02	0.01
query8	0.04	0.04	0.03
query9	0.58	0.51	0.51
query10	0.57	0.60	0.57
query11	0.16	0.11	0.11
query12	0.14	0.12	0.11
query13	0.60	0.62	0.60
query14	2.67	2.84	2.82
query15	0.92	0.85	0.87
query16	0.39	0.37	0.38
query17	1.06	1.03	1.03
query18	0.21	0.20	0.19
query19	1.94	2.00	1.81
query20	0.01	0.01	0.02
query21	15.36	0.93	0.57
query22	0.75	1.12	0.69
query23	15.01	1.39	0.69
query24	7.15	1.73	0.78
query25	0.47	0.20	0.21
query26	0.57	0.16	0.13
query27	0.05	0.05	0.05
query28	9.80	0.86	0.44
query29	12.53	3.92	3.29
query30	0.24	0.09	0.07
query31	2.82	0.59	0.40
query32	3.23	0.54	0.47
query33	3.00	3.05	3.06
query34	15.78	5.21	4.51
query35	4.59	4.57	4.53
query36	0.66	0.49	0.48
query37	0.08	0.06	0.06
query38	0.05	0.04	0.04
query39	0.03	0.03	0.02
query40	0.18	0.13	0.13
query41	0.08	0.03	0.02
query42	0.04	0.03	0.02
query43	0.03	0.03	0.03
Total cold run time: 105.61 s
Total hot run time: 31.5 s

@zclllyybb zclllyybb force-pushed the fix_date_diff_ms branch 2 times, most recently from 21e42b1 to 948f899 Compare March 26, 2025 15:39
@zclllyybb
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	26248	5069	5034	5034
q2	2068	292	166	166
q3	10403	1261	686	686
q4	10213	1034	571	571
q5	7566	2424	2369	2369
q6	187	165	132	132
q7	922	768	613	613
q8	9325	1296	1112	1112
q9	6892	5175	5263	5175
q10	6884	2322	1878	1878
q11	485	277	249	249
q12	353	354	224	224
q13	17771	3865	3096	3096
q14	236	230	205	205
q15	534	496	489	489
q16	641	603	575	575
q17	593	873	356	356
q18	7596	7395	7157	7157
q19	2258	997	569	569
q20	331	336	192	192
q21	3987	2613	2429	2429
q22	1061	1042	956	956
Total cold run time: 116554 ms
Total hot run time: 34233 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5271	5111	5101	5101
q2	246	331	228	228
q3	2164	2659	2299	2299
q4	1458	1832	1526	1526
q5	4499	4457	4431	4431
q6	220	177	130	130
q7	2030	1927	1768	1768
q8	2641	2596	2545	2545
q9	7434	7079	7253	7079
q10	3044	3186	2780	2780
q11	575	500	487	487
q12	684	767	613	613
q13	3563	3879	3352	3352
q14	279	301	284	284
q15	522	468	468	468
q16	650	670	658	658
q17	1170	1541	1425	1425
q18	7826	7584	7514	7514
q19	842	882	1003	882
q20	1919	2034	1848	1848
q21	5313	4867	4756	4756
q22	1145	1073	1034	1034
Total cold run time: 53495 ms
Total hot run time: 51208 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 192889 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 948f899e555435bf7ab0ef5365b3d37bc6ff6c24, data reload: false

query1	1402	1059	1034	1034
query2	6182	1918	1947	1918
query3	11152	4687	4695	4687
query4	25980	23659	22926	22926
query5	4307	642	501	501
query6	315	205	193	193
query7	3984	499	268	268
query8	301	250	249	249
query9	8478	2534	2515	2515
query10	479	319	266	266
query11	15689	15094	14786	14786
query12	162	110	106	106
query13	1545	528	391	391
query14	9180	6109	6079	6079
query15	205	191	169	169
query16	7494	650	492	492
query17	1172	701	602	602
query18	2032	423	331	331
query19	208	223	186	186
query20	134	128	118	118
query21	215	121	111	111
query22	4361	4648	4334	4334
query23	34648	33600	33573	33573
query24	8036	2432	2440	2432
query25	539	486	439	439
query26	735	278	148	148
query27	3110	512	338	338
query28	4469	2431	2464	2431
query29	601	583	489	489
query30	269	222	189	189
query31	890	870	788	788
query32	72	66	65	65
query33	538	369	317	317
query34	795	866	504	504
query35	795	842	745	745
query36	989	1014	913	913
query37	121	104	80	80
query38	4139	4198	4174	4174
query39	1590	1454	1427	1427
query40	208	119	99	99
query41	52	55	50	50
query42	129	113	116	113
query43	511	496	481	481
query44	1325	820	828	820
query45	180	178	170	170
query46	873	1024	661	661
query47	1883	1943	1806	1806
query48	384	420	313	313
query49	710	506	456	456
query50	714	743	417	417
query51	4310	4333	4320	4320
query52	113	116	98	98
query53	222	249	175	175
query54	509	502	419	419
query55	81	89	81	81
query56	261	279	280	279
query57	1159	1192	1126	1126
query58	269	255	240	240
query59	2750	2817	2821	2817
query60	304	279	283	279
query61	141	135	131	131
query62	776	747	671	671
query63	223	180	182	180
query64	2966	1057	692	692
query65	4492	4359	4373	4359
query66	934	434	288	288
query67	16500	15615	15623	15615
query68	9554	897	519	519
query69	490	293	261	261
query70	1237	1048	1108	1048
query71	465	296	266	266
query72	5821	4767	4908	4767
query73	707	650	357	357
query74	8969	9147	8707	8707
query75	4388	3259	2741	2741
query76	3652	1188	747	747
query77	965	369	274	274
query78	10187	10370	9353	9353
query79	1564	814	564	564
query80	672	523	440	440
query81	502	261	220	220
query82	444	129	96	96
query83	209	249	154	154
query84	286	90	73	73
query85	768	354	310	310
query86	350	319	279	279
query87	4419	4511	4263	4263
query88	2934	2250	2247	2247
query89	397	306	282	282
query90	1898	213	210	210
query91	157	142	107	107
query92	76	59	55	55
query93	1185	1090	583	583
query94	669	388	312	312
query95	361	272	287	272
query96	493	553	278	278
query97	3164	3241	3172	3172
query98	216	210	202	202
query99	1464	1396	1260	1260
Total cold run time: 278955 ms
Total hot run time: 192889 ms

@doris-robot
Copy link

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

query1	0.03	0.03	0.03
query2	0.12	0.11	0.10
query3	0.25	0.19	0.20
query4	1.59	0.19	0.19
query5	0.59	0.57	0.59
query6	1.18	0.72	0.71
query7	0.02	0.02	0.02
query8	0.05	0.03	0.03
query9	0.58	0.53	0.51
query10	0.56	0.59	0.56
query11	0.16	0.11	0.10
query12	0.14	0.11	0.11
query13	0.61	0.61	0.60
query14	2.79	2.73	2.81
query15	0.93	0.85	0.87
query16	0.38	0.38	0.37
query17	1.00	1.00	1.01
query18	0.22	0.19	0.20
query19	1.90	1.93	1.82
query20	0.02	0.01	0.02
query21	15.35	0.89	0.56
query22	0.75	1.07	0.68
query23	15.03	1.41	0.61
query24	6.83	1.75	1.46
query25	0.51	0.15	0.09
query26	0.59	0.16	0.13
query27	0.05	0.05	0.04
query28	10.53	0.82	0.42
query29	12.53	4.02	3.32
query30	0.25	0.10	0.06
query31	2.82	0.58	0.38
query32	3.23	0.55	0.47
query33	3.02	3.06	3.09
query34	15.78	5.12	4.56
query35	4.56	4.57	4.56
query36	0.66	0.50	0.48
query37	0.09	0.06	0.06
query38	0.06	0.05	0.04
query39	0.03	0.03	0.03
query40	0.17	0.13	0.14
query41	0.09	0.03	0.03
query42	0.03	0.02	0.03
query43	0.04	0.03	0.03
Total cold run time: 106.12 s
Total hot run time: 31.91 s

@zclllyybb
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	26202	5151	5084	5084
q2	2068	289	166	166
q3	10387	1302	720	720
q4	10234	1001	527	527
q5	7535	2458	2375	2375
q6	200	165	135	135
q7	934	748	610	610
q8	9336	1326	1157	1157
q9	6874	5186	5203	5186
q10	6836	2325	1938	1938
q11	467	279	255	255
q12	366	370	224	224
q13	17793	3783	3111	3111
q14	230	223	222	222
q15	545	485	481	481
q16	618	618	573	573
q17	621	900	367	367
q18	7582	7131	7267	7131
q19	1654	981	583	583
q20	339	337	194	194
q21	3870	3386	2395	2395
q22	1038	1015	937	937
Total cold run time: 115729 ms
Total hot run time: 34371 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5278	5228	5218	5218
q2	250	342	245	245
q3	2225	2700	2306	2306
q4	1502	1914	1448	1448
q5	4537	4470	4406	4406
q6	221	172	127	127
q7	2024	1919	1774	1774
q8	2650	2584	2541	2541
q9	7339	7127	7257	7127
q10	3026	3201	2763	2763
q11	586	521	488	488
q12	722	745	597	597
q13	3529	3923	3370	3370
q14	301	288	267	267
q15	530	474	479	474
q16	651	682	663	663
q17	1199	1584	1440	1440
q18	7836	7526	7515	7515
q19	913	897	1081	897
q20	1970	1970	1858	1858
q21	5310	4876	4714	4714
q22	1113	1062	1044	1044
Total cold run time: 53712 ms
Total hot run time: 51282 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 194831 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 30bbabbdb52d4320073411c65be7e2dc2c8aac85, data reload: false

query1	1416	1102	1066	1066
query2	6195	2005	1966	1966
query3	11012	4610	4649	4610
query4	25756	23969	23515	23515
query5	4960	686	502	502
query6	316	205	198	198
query7	3997	508	274	274
query8	326	251	237	237
query9	8503	2578	2553	2553
query10	510	320	280	280
query11	16065	15246	15161	15161
query12	163	115	112	112
query13	1715	564	401	401
query14	10225	6345	6432	6345
query15	211	186	163	163
query16	7634	673	475	475
query17	1282	740	573	573
query18	2073	424	315	315
query19	201	193	169	169
query20	121	118	115	115
query21	204	130	108	108
query22	4601	4436	4394	4394
query23	34286	33997	33623	33623
query24	8278	2459	2492	2459
query25	514	483	407	407
query26	723	269	145	145
query27	3159	506	335	335
query28	4770	2475	2440	2440
query29	662	581	461	461
query30	285	221	204	204
query31	913	917	823	823
query32	76	62	64	62
query33	523	379	329	329
query34	808	893	524	524
query35	805	870	772	772
query36	1018	1009	921	921
query37	129	101	79	79
query38	4219	4297	4155	4155
query39	1493	1495	1477	1477
query40	216	120	103	103
query41	54	60	53	53
query42	126	107	110	107
query43	515	526	509	509
query44	1349	850	833	833
query45	192	181	167	167
query46	887	1036	665	665
query47	1798	1874	1796	1796
query48	396	474	305	305
query49	727	525	458	458
query50	745	771	437	437
query51	4324	4319	4221	4221
query52	121	111	102	102
query53	238	266	182	182
query54	513	524	463	463
query55	89	86	86	86
query56	285	272	282	272
query57	1182	1201	1115	1115
query58	274	295	253	253
query59	2937	2905	2762	2762
query60	290	291	272	272
query61	132	134	123	123
query62	754	753	671	671
query63	241	196	189	189
query64	3039	1096	733	733
query65	4513	4357	4363	4357
query66	796	396	294	294
query67	16072	15493	15369	15369
query68	8282	891	514	514
query69	491	301	277	277
query70	1216	1113	1118	1113
query71	401	311	275	275
query72	5609	4689	4847	4689
query73	685	652	357	357
query74	8998	9377	9139	9139
query75	3254	3254	2746	2746
query76	3087	1193	801	801
query77	499	389	287	287
query78	9871	10113	9350	9350
query79	2004	827	575	575
query80	625	547	528	528
query81	469	263	223	223
query82	203	126	100	100
query83	182	173	164	164
query84	231	94	86	86
query85	755	360	302	302
query86	322	314	295	295
query87	4381	4603	4381	4381
query88	3455	2259	2245	2245
query89	392	321	281	281
query90	1993	219	220	219
query91	138	138	105	105
query92	76	67	57	57
query93	1120	1053	598	598
query94	702	408	303	303
query95	354	288	270	270
query96	497	570	276	276
query97	3190	3224	3164	3164
query98	227	209	197	197
query99	1330	1420	1269	1269
Total cold run time: 277991 ms
Total hot run time: 194831 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 30bbabbdb52d4320073411c65be7e2dc2c8aac85, data reload: false

query1	0.04	0.03	0.03
query2	0.12	0.11	0.11
query3	0.23	0.19	0.20
query4	1.59	0.20	0.20
query5	0.59	0.57	0.58
query6	1.17	0.72	0.72
query7	0.02	0.02	0.02
query8	0.05	0.03	0.03
query9	0.57	0.51	0.52
query10	0.63	0.58	0.57
query11	0.15	0.11	0.10
query12	0.14	0.11	0.12
query13	0.63	0.59	0.61
query14	2.65	2.68	2.74
query15	0.92	0.85	0.85
query16	0.40	0.38	0.40
query17	1.01	1.02	1.05
query18	0.21	0.20	0.20
query19	1.82	1.86	1.84
query20	0.02	0.01	0.01
query21	15.35	0.90	0.56
query22	0.76	1.23	0.64
query23	14.95	1.37	0.64
query24	7.33	0.73	0.60
query25	0.48	0.22	0.07
query26	0.62	0.16	0.13
query27	0.06	0.05	0.05
query28	9.04	0.90	0.45
query29	12.53	3.93	3.28
query30	0.24	0.09	0.06
query31	2.86	0.56	0.39
query32	3.23	0.54	0.47
query33	3.00	3.01	3.13
query34	15.81	5.12	4.50
query35	4.50	4.49	4.51
query36	0.65	0.50	0.48
query37	0.08	0.06	0.06
query38	0.05	0.04	0.03
query39	0.03	0.02	0.03
query40	0.16	0.13	0.13
query41	0.09	0.03	0.03
query42	0.04	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 104.86 s
Total hot run time: 30.87 s

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 71.43% (20/28) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 50.90% (13626/26769)
Line Coverage 40.27% (118272/293711)
Region Coverage 38.94% (60076/154276)
Branch Coverage 33.86% (30225/89268)

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

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

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

@BiteTheDDDDt BiteTheDDDDt merged commit c962900 into apache:master Apr 21, 2025
24 of 26 checks passed
@zclllyybb zclllyybb deleted the fix_date_diff_ms branch April 21, 2025 04:14
zclllyybb added a commit to zclllyybb/doris that referenced this pull request May 6, 2025
…than day (apache#49429)

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

should consider the microseconds' effect.

before:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         24 |
+------------------------------------------------------------+
```
now:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         23 |
+------------------------------------------------------------+
```

fix the wrong floor of function date_diff when unit less than day

- Test <!-- At least one of them must be included. -->
    - [x] 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:
    - [x] No.
    - [ ] Yes. <!-- Explain the behavior change -->

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

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
zclllyybb added a commit to zclllyybb/doris that referenced this pull request May 6, 2025
…than day (apache#49429)

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

should consider the microseconds' effect.

before:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         24 |
+------------------------------------------------------------+
```
now:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         23 |
+------------------------------------------------------------+
```

fix the wrong floor of function date_diff when unit less than day

- Test <!-- At least one of them must be included. -->
    - [x] 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:
    - [x] No.
    - [ ] Yes. <!-- Explain the behavior change -->

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

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
zclllyybb added a commit to zclllyybb/doris that referenced this pull request May 6, 2025
…than day (apache#49429)

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

should consider the microseconds' effect.

before:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         24 |
+------------------------------------------------------------+
```
now:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         23 |
+------------------------------------------------------------+
```

fix the wrong floor of function date_diff when unit less than day

- Test <!-- At least one of them must be included. -->
    - [x] 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:
    - [x] No.
    - [ ] Yes. <!-- Explain the behavior change -->

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

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
yiguolei pushed a commit that referenced this pull request May 7, 2025
dataroaring pushed a commit that referenced this pull request May 7, 2025
@yiguolei yiguolei mentioned this pull request May 13, 2025
koarz pushed a commit to koarz/doris that referenced this pull request Jun 4, 2025
…than day (apache#49429)

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

should consider the microseconds' effect.

before:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         24 |
+------------------------------------------------------------+
```
now:
```sql
mysql> select hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1');
+------------------------------------------------------------+
| hours_diff('2023-10-15 00:00:00', '2023-10-14 00:00:00.1') |
+------------------------------------------------------------+
|                                                         23 |
+------------------------------------------------------------+
```

fix the wrong floor of function date_diff when unit less than day

- Test <!-- At least one of them must be included. -->
    - [x] 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:
    - [x] No.
    - [ ] Yes. <!-- Explain the behavior change -->

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

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
morrySnow pushed a commit that referenced this pull request Oct 15, 2025
…56893)

### What problem does this PR solve?

Related PR: #49429

Problem Summary:

only fix in 3.1

before:
mysql> select hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) from my_doris_table;
+-----------------------------------------------------------------+
| hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) |
+-----------------------------------------------------------------+
|                                                    103079215078 |
+-----------------------------------------------------------------+

now:
mysql> select hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) from my_doris_table;
+-----------------------------------------------------------------+
| hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) |
+-----------------------------------------------------------------+
|                                                             -24 |
+-----------------------------------------------------------------+
Hastyshell pushed a commit to Hastyshell/doris that referenced this pull request Nov 12, 2025
…ev1 (apache#5237)

pick apache#54967


Related PR: apache#49429

Problem Summary:

before:
```sql
mysql> select hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) from my_doris_table;
+-----------------------------------------------------------------+
| hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) |
+-----------------------------------------------------------------+
|                                                    103079215078 |
+-----------------------------------------------------------------+
```
now:
```sql
mysql> select hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) from my_doris_table;
+-----------------------------------------------------------------+
| hours_diff(now(), date_format(event_date, '%Y-%m-%d %H:00:00')) |
+-----------------------------------------------------------------+
|                                                             -24 |
+-----------------------------------------------------------------+
```

and make fe fold of `now()` return v2 type

### Release note

Fix wrong calculation of timestampdiff of datetimev1
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.10-merged dev/3.0.6-merged p0_w reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants