Skip to content

Conversation

@linrrzqqq
Copy link
Contributor

@linrrzqqq linrrzqqq commented Dec 10, 2025

What problem does this PR solve?

Issue Number: #48203

Related PR: #57569

Problem Summary:

Release note

doc: apache/doris-website#3176

The INTERVAL function uses binary search to return the index of the first threshold strictly greater than N.

SELECT INTERVAL(0, 1, 10, 100);
+--------------------------+
| INTERVAL(0, 1, 10, 100)  |
+--------------------------+
|                        0 |
+--------------------------+

SELECT INTERVAL(10, 1, 10, 100, 1000);
+-----------------------------------+
| INTERVAL(10, 1, 10, 100, 1000)   |
+-----------------------------------+
|                                 2 |
+-----------------------------------+

-- First parameter is NULL
SELECT INTERVAL(NULL, 1, 10, 100);
+----------------------------+
| INTERVAL(NULL, 1, 10, 100) |
+----------------------------+
|                         -1 |
+----------------------------+

-- Subsequent parameters are NULL, treated as 0
SELECT INTERVAL(3, -1, NULL, 2, 3, 4);
+--------------------------------+
| INTERVAL(3, -1, NULL, 2, 3, 4) |
+--------------------------------+
|                              4 |
+--------------------------------+

None

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?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@linrrzqqq linrrzqqq requested a review from zclllyybb as a code owner December 10, 2025 02:51
@Thearas
Copy link
Contributor

Thearas commented Dec 10, 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?

@zclllyybb zclllyybb self-assigned this Dec 10, 2025
@linrrzqqq
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 4.35% (1/23) 🎉
Increment coverage report
Complete coverage report

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17690	5024	4978	4978
q2	2079	349	232	232
q3	10153	1352	733	733
q4	10217	844	334	334
q5	7530	2191	1954	1954
q6	190	178	137	137
q7	1000	887	726	726
q8	9378	1480	1158	1158
q9	7124	5349	5295	5295
q10	6833	2377	1955	1955
q11	536	324	312	312
q12	697	727	581	581
q13	17822	3731	3029	3029
q14	299	289	274	274
q15	598	525	513	513
q16	929	916	852	852
q17	710	814	519	519
q18	7718	7168	7163	7163
q19	1096	970	629	629
q20	406	387	256	256
q21	4260	4021	3617	3617
q22	1065	1018	952	952
Total cold run time: 108330 ms
Total hot run time: 36199 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4945	4915	4935	4915
q2	341	411	335	335
q3	2170	2694	2328	2328
q4	1310	1757	1310	1310
q5	5068	4652	4586	4586
q6	214	171	131	131
q7	2053	1940	1866	1866
q8	2739	2652	2576	2576
q9	7651	7654	7438	7438
q10	3069	3245	2810	2810
q11	605	577	536	536
q12	663	764	601	601
q13	3535	3750	3284	3284
q14	297	333	272	272
q15	551	525	497	497
q16	895	925	1008	925
q17	1182	1488	1433	1433
q18	7745	7814	7585	7585
q19	884	855	908	855
q20	2073	2106	1940	1940
q21	5053	4529	4238	4238
q22	1121	1067	1004	1004
Total cold run time: 54164 ms
Total hot run time: 51465 ms

@doris-robot
Copy link

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

query5	4444	632	463	463
query6	333	253	219	219
query7	4211	464	271	271
query8	332	278	240	240
query9	8756	2632	2664	2632
query10	496	392	337	337
query11	15208	14843	14517	14517
query12	193	122	118	118
query13	1277	515	408	408
query14	6125	3289	3062	3062
query14_1	2910	2904	2884	2884
query15	205	193	179	179
query16	908	436	445	436
query17	1089	687	578	578
query18	2559	427	333	333
query19	227	223	201	201
query20	128	122	109	109
query21	217	137	113	113
query22	4190	4125	4014	4014
query23	16515	16179	15896	15896
query23_1	16064	16110	16194	16110
query24	7343	1663	1232	1232
query24_1	1235	1237	1251	1237
query25	557	472	413	413
query26	1256	286	173	173
query27	2721	472	317	317
query28	4451	2181	2165	2165
query29	864	550	437	437
query30	315	245	214	214
query31	808	711	615	615
query32	73	65	66	65
query33	524	319	287	287
query34	911	893	537	537
query35	786	815	722	722
query36	859	917	859	859
query37	131	93	91	91
query38	3781	3873	3771	3771
query39	750	752	722	722
query39_1	687	695	699	695
query40	224	148	122	122
query41	66	63	62	62
query42	108	104	112	104
query43	446	436	402	402
query44	1321	770	758	758
query45	197	193	183	183
query46	869	976	612	612
query47	1695	1725	1664	1664
query48	316	330	247	247
query49	624	455	353	353
query50	680	302	217	217
query51	3863	3815	3838	3815
query52	103	108	99	99
query53	315	344	296	296
query54	291	263	254	254
query55	81	78	68	68
query56	299	302	294	294
query57	1146	1158	1079	1079
query58	270	255	258	255
query59	2333	2399	2347	2347
query60	318	310	284	284
query61	161	158	177	158
query62	699	669	635	635
query63	322	294	288	288
query64	4990	1289	1015	1015
query65	4015	3912	3965	3912
query66	1432	453	340	340
query67	15517	14877	14932	14877
query68	2703	1077	798	798
query69	460	369	318	318
query70	1029	1040	974	974
query71	333	315	284	284
query72	6222	5121	5171	5121
query73	521	578	308	308
query74	8782	8792	8560	8560
query75	3501	3551	3147	3147
query76	2892	1138	736	736
query77	366	398	293	293
query78	9488	9512	8883	8883
query79	1848	841	609	609
query80	1344	657	567	567
query81	554	271	237	237
query82	401	133	105	105
query83	272	257	244	244
query84	258	125	101	101
query85	905	507	463	463
query86	428	297	307	297
query87	4009	4076	3968	3968
query88	3538	2289	2269	2269
query89	454	420	402	402
query90	2231	162	153	153
query91	170	177	143	143
query92	85	79	66	66
query93	2507	911	583	583
query94	540	317	261	261
query95	578	325	309	309
query96	583	471	211	211
query97	2628	2663	2567	2567
query98	217	205	195	195
query99	1231	1304	1217	1217
Total cold run time: 258318 ms
Total hot run time: 181420 ms

@doris-robot
Copy link

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

query1	0.05	0.04	0.04
query2	0.10	0.04	0.04
query3	0.25	0.09	0.09
query4	1.60	0.11	0.11
query5	0.26	0.26	0.26
query6	1.18	0.65	0.63
query7	0.03	0.02	0.02
query8	0.05	0.04	0.04
query9	0.57	0.52	0.49
query10	0.56	0.56	0.55
query11	0.15	0.10	0.12
query12	0.15	0.11	0.12
query13	0.61	0.60	0.61
query14	0.99	0.99	0.97
query15	0.82	0.82	0.80
query16	0.40	0.43	0.40
query17	1.03	1.02	1.05
query18	0.23	0.21	0.21
query19	1.84	1.89	1.75
query20	0.02	0.01	0.01
query21	15.45	0.29	0.14
query22	4.87	0.05	0.05
query23	16.10	0.28	0.10
query24	1.82	0.33	0.62
query25	0.08	0.05	0.05
query26	0.15	0.13	0.13
query27	0.09	0.09	0.05
query28	4.36	1.22	1.02
query29	12.56	4.18	3.20
query30	0.28	0.13	0.11
query31	2.82	0.60	0.40
query32	3.24	0.55	0.45
query33	3.01	3.13	3.03
query34	16.78	5.17	4.52
query35	4.56	4.60	4.53
query36	0.68	0.50	0.48
query37	0.11	0.07	0.07
query38	0.07	0.04	0.03
query39	0.05	0.03	0.04
query40	0.17	0.15	0.13
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 98.31 s
Total hot run time: 27.18 s

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 10.53% (10/95) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.36% (18718/35079)
Line Coverage 39.06% (173059/443007)
Region Coverage 33.78% (134366/397793)
Branch Coverage 34.66% (57689/166452)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 10.53% (10/95) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 58.20% (20010/34381)
Line Coverage 43.86% (194082/442531)
Region Coverage 38.57% (155239/402516)
Branch Coverage 39.24% (65659/167327)

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 95.65% (22/23) 🎉
Increment coverage report
Complete coverage report

@linrrzqqq
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 4.35% (1/23) 🎉
Increment coverage report
Complete coverage report

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17612	4290	4045	4045
q2	2051	357	234	234
q3	10185	1310	739	739
q4	10221	889	341	341
q5	7519	2147	1960	1960
q6	185	173	141	141
q7	991	874	715	715
q8	9360	1388	1168	1168
q9	7237	5373	5327	5327
q10	6837	2398	1983	1983
q11	521	312	299	299
q12	686	733	581	581
q13	17785	3711	2990	2990
q14	291	299	270	270
q15	592	527	510	510
q16	926	911	858	858
q17	712	780	580	580
q18	8054	7177	7122	7122
q19	1123	964	621	621
q20	402	363	251	251
q21	4251	3913	3878	3878
q22	1059	1010	980	980
Total cold run time: 108600 ms
Total hot run time: 35593 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4072	4037	4036	4036
q2	331	428	318	318
q3	2183	2701	2255	2255
q4	1333	1763	1308	1308
q5	4261	4937	4722	4722
q6	219	180	137	137
q7	2054	2014	1875	1875
q8	2681	2536	2541	2536
q9	7794	7505	7596	7505
q10	3137	3258	2824	2824
q11	631	524	494	494
q12	688	750	604	604
q13	3646	3975	3385	3385
q14	311	307	266	266
q15	568	502	519	502
q16	949	925	890	890
q17	1206	1639	1441	1441
q18	7810	7600	7484	7484
q19	891	828	928	828
q20	1995	2183	1918	1918
q21	4866	4312	4100	4100
q22	1102	1036	981	981
Total cold run time: 52728 ms
Total hot run time: 50409 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 181433 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 38adcb8c19239580677482f2f7a2bfbb32e49a4e, data reload: false

query5	5054	641	472	472
query6	343	227	205	205
query7	4209	471	270	270
query8	304	254	243	243
query9	8782	2575	2571	2571
query10	538	386	352	352
query11	15294	14821	14550	14550
query12	179	121	117	117
query13	1272	506	389	389
query14	6216	3248	3058	3058
query14_1	2926	2863	2899	2863
query15	212	199	178	178
query16	896	487	465	465
query17	1123	721	610	610
query18	2565	444	356	356
query19	239	233	209	209
query20	128	116	118	116
query21	226	153	118	118
query22	3986	4061	3895	3895
query23	16592	16066	16007	16007
query23_1	16243	16341	16019	16019
query24	7475	1670	1219	1219
query24_1	1240	1222	1233	1222
query25	596	492	442	442
query26	1268	283	164	164
query27	2720	468	310	310
query28	4454	2172	2159	2159
query29	847	586	435	435
query30	319	248	221	221
query31	838	710	613	613
query32	79	65	67	65
query33	553	338	288	288
query34	889	899	532	532
query35	780	826	758	758
query36	862	894	808	808
query37	128	94	78	78
query38	3829	3836	3816	3816
query39	744	736	721	721
query39_1	699	689	700	689
query40	225	140	119	119
query41	68	68	63	63
query42	108	107	104	104
query43	434	419	401	401
query44	1319	765	740	740
query45	196	192	182	182
query46	884	990	618	618
query47	1664	1692	1631	1631
query48	324	331	241	241
query49	675	458	359	359
query50	663	299	219	219
query51	3824	3795	3814	3795
query52	102	109	95	95
query53	326	345	290	290
query54	282	269	254	254
query55	84	78	73	73
query56	295	297	320	297
query57	1139	1120	1102	1102
query58	276	262	285	262
query59	2358	2443	2342	2342
query60	329	311	291	291
query61	171	157	159	157
query62	703	672	626	626
query63	319	295	300	295
query64	4973	1325	1013	1013
query65	4027	3934	3951	3934
query66	1428	449	319	319
query67	15108	14806	14798	14798
query68	6575	1002	737	737
query69	500	349	308	308
query70	1071	1006	981	981
query71	398	313	281	281
query72	6066	5024	5016	5016
query73	690	603	315	315
query74	8892	8717	8570	8570
query75	3587	3515	3158	3158
query76	3921	1133	724	724
query77	538	398	293	293
query78	9531	9677	8901	8901
query79	1724	840	609	609
query80	754	648	564	564
query81	495	271	232	232
query82	235	133	104	104
query83	267	269	240	240
query84	264	117	106	106
query85	912	512	459	459
query86	330	307	290	290
query87	4100	4052	4062	4052
query88	3178	2281	2250	2250
query89	472	425	390	390
query90	1995	157	151	151
query91	180	165	147	147
query92	71	70	65	65
query93	1133	902	576	576
query94	480	297	283	283
query95	583	373	312	312
query96	598	455	210	210
query97	2605	2680	2585	2585
query98	208	196	193	193
query99	1283	1270	1211	1211
Total cold run time: 261281 ms
Total hot run time: 181433 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.04
query2	0.10	0.04	0.05
query3	0.25	0.10	0.09
query4	1.61	0.12	0.11
query5	0.28	0.24	0.25
query6	1.17	0.64	0.63
query7	0.03	0.03	0.03
query8	0.06	0.04	0.04
query9	0.57	0.53	0.51
query10	0.57	0.56	0.55
query11	0.16	0.11	0.11
query12	0.15	0.11	0.13
query13	0.61	0.60	0.60
query14	0.99	0.97	1.00
query15	0.82	0.80	0.81
query16	0.40	0.41	0.38
query17	1.08	1.05	1.03
query18	0.23	0.21	0.22
query19	1.90	1.89	1.86
query20	0.02	0.01	0.01
query21	15.46	0.30	0.14
query22	4.88	0.06	0.04
query23	15.96	0.27	0.10
query24	1.82	0.66	0.85
query25	0.08	0.08	0.07
query26	0.13	0.13	0.14
query27	0.07	0.08	0.07
query28	5.60	1.21	1.03
query29	12.58	4.16	3.25
query30	0.28	0.14	0.11
query31	2.83	0.62	0.40
query32	3.23	0.55	0.46
query33	3.01	2.99	3.00
query34	16.82	5.21	4.53
query35	4.50	4.54	4.56
query36	0.66	0.50	0.50
query37	0.11	0.07	0.06
query38	0.07	0.04	0.04
query39	0.04	0.04	0.03
query40	0.17	0.15	0.13
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 99.54 s
Total hot run time: 27.73 s

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 10.31% (10/97) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.35% (18720/35087)
Line Coverage 39.05% (173074/443177)
Region Coverage 33.70% (134092/397918)
Branch Coverage 34.65% (57700/166520)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 86.60% (84/97) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 72.24% (24842/34389)
Line Coverage 58.99% (261139/442701)
Region Coverage 53.98% (217349/402641)
Branch Coverage 55.47% (92852/167395)

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 95.65% (22/23) 🎉
Increment coverage report
Complete coverage report

@zclllyybb zclllyybb changed the title [Feature](func) Support INTERVAL function [Feature](func) Support INTERVAL function and fix EXPORT_SET constant process Dec 15, 2025
return false;
}

static void collect_columns_info(std::vector<ColumnWithConstAndNullMap>& columns_info,
Copy link
Contributor

Choose a reason for hiding this comment

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

利用这一套似乎并没有怎么简化代码。就自己手工处理下const和nullable就行了吧?

if (value < thresholds[0].getValue()) {
return new IntegerLiteral(0);
}
int l = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

java有没有类似upper_bound的标准库函数?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants