Skip to content

[feature](timestamp_ns) Support casts, functions and external tables - #66761

Open
jacktengg wants to merge 5 commits into
apache:masterfrom
jacktengg:timestamp_ns-split-commit1-cast-and-functions
Open

[feature](timestamp_ns) Support casts, functions and external tables#66761
jacktengg wants to merge 5 commits into
apache:masterfrom
jacktengg:timestamp_ns-split-commit1-cast-and-functions

Conversation

@jacktengg

@jacktengg jacktengg commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:
TIMESTAMP_NS basic type support did not include the cast matrix or the date-time function surface available to DATETIMEV2. Queries that converted TIMESTAMP_NS values, combined them with other temporal types, or used date arithmetic, extraction, formatting, aggregate, window, and conditional functions could fail during analysis or backend function resolution. This change adds explicit FE signatures and coercion rules together with BE vectorized implementations. Nanoseconds are preserved when the result remains TIMESTAMP_NS, conversions to lower-precision types use existing rounding semantics, and operations that leave the signed epoch-nanosecond domain report an error instead of wrapping.

TIMESTAMP_NS external table integration of Iceberg, Paimon, ADBC, JNI scanner, Parquet, and ORC mappings, etc.

Release note

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?

    • 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
Copy Markdown
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?

@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 74.33% (805/1083) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 85.49% (1726/2019) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.10% (32687/42953)
Line Coverage 61.05% (366948/601071)
Region Coverage 57.70% (308488/534662)
Branch Coverage 59.03% (140059/237287)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 68.44% (811/1185) 🎉
Increment coverage report
Complete coverage report

@jacktengg
jacktengg force-pushed the timestamp_ns-split-commit1-cast-and-functions branch from a75a76c to f7b433d Compare August 14, 2026 17:03
@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.23% (2001/2558)
Line Coverage 65.30% (36509/55907)
Region Coverage 65.47% (18559/28347)
Branch Coverage 55.11% (10100/18328)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17548	3076	3071	3071
q2	1878	246	153	153
q3	10469	894	500	500
q4	4667	246	195	195
q5	7687	576	386	386
q6	144	123	94	94
q7	527	506	382	382
q8	9243	905	989	905
q9	3452	2362	2360	2360
q10	6521	869	705	705
q11	446	265	239	239
q12	710	384	324	324
q13	17873	1937	1495	1495
q14	164	155	138	138
q15	q16	448	397	364	364
q17	827	915	799	799
q18	3085	2219	2253	2219
q19	1140	922	806	806
q20	713	517	480	480
q21	5298	1750	1904	1750
q22	337	273	238	238
Total cold run time: 93177 ms
Total hot run time: 17603 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3462	3353	3358	3353
q2	209	220	157	157
q3	2236	2325	2132	2132
q4	1173	1162	876	876
q5	2195	2111	2107	2107
q6	174	118	87	87
q7	1022	919	867	867
q8	1610	1414	1411	1411
q9	3062	3055	3028	3028
q10	1851	1813	1624	1624
q11	352	272	248	248
q12	460	444	341	341
q13	1781	1832	1529	1529
q14	185	168	155	155
q15	q16	396	386	366	366
q17	1043	1024	1029	1024
q18	4867	4369	4682	4369
q19	907	854	866	854
q20	983	911	822	822
q21	3798	3107	3247	3107
q22	418	361	322	322
Total cold run time: 32184 ms
Total hot run time: 28779 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 84745 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 f7b433db32b2e9d45ea2a49fd9813e18b89c1aea, data reload: false

query5	4233	410	319	319
query6	399	157	146	146
query7	4916	471	251	251
query8	296	118	115	115
query9	8679	2905	2894	2894
query10	402	262	221	221
query11	5373	1035	911	911
query12	121	73	72	72
query13	1206	460	344	344
query14	5953	1998	1864	1864
query14_1	1774	1746	1756	1746
query15	174	117	108	108
query16	939	406	389	389
query17	822	449	365	365
query18	2338	337	247	247
query19	179	147	120	120
query20	84	73	70	70
query21	211	115	103	103
query22	5426	5303	5450	5303
query23	7206	6585	6296	6296
query23_1	6582	6465	6476	6465
query24	7241	1111	764	764
query24_1	762	810	803	803
query25	433	330	262	262
query26	1265	268	169	169
query27	2726	468	283	283
query28	4589	1527	1497	1497
query29	956	446	362	362
query30	275	177	153	153
query31	968	661	599	599
query32	110	53	54	53
query33	473	221	181	181
query34	993	854	504	504
query35	407	394	348	348
query36	567	557	527	527
query37	132	87	74	74
query38	1005	841	816	816
query39	509	515	534	515
query39_1	513	515	546	515
query40	224	159	109	109
query41	55	52	49	49
query42	74	71	71	71
query43	251	246	230	230
query44	1018	570	577	570
query45	104	100	102	100
query46	819	835	555	555
query47	907	962	957	957
query48	336	315	217	217
query49	539	245	186	186
query50	835	337	259	259
query51	8181	8178	8087	8087
query52	69	72	60	60
query53	201	220	153	153
query54	241	200	161	161
query55	71	59	54	54
query56	228	213	214	213
query57	639	594	602	594
query58	211	185	187	185
query59	1079	1091	951	951
query60	245	219	196	196
query61	132	125	109	109
query62	353	205	168	168
query63	187	165	157	157
query64	2674	654	580	580
query65	1525	1524	1562	1524
query66	1782	296	238	238
query67	9864	9842	9485	9485
query68	3030	1174	797	797
query69	340	219	203	203
query70	661	589	611	589
query71	305	246	232	232
query72	2355	1878	1551	1551
query73	645	605	348	348
query74	2004	1231	1166	1166
query75	1220	1132	1005	1005
query76	2367	735	580	580
query77	249	267	195	195
query78	5229	4893	4393	4393
query79	1179	911	570	570
query80	1196	384	349	349
query81	489	194	171	171
query82	626	136	105	105
query83	320	253	229	229
query84	306	127	101	101
query85	827	431	388	388
query86	391	189	171	171
query87	1010	964	889	889
query88	2842	2152	2135	2135
query89	306	228	205	205
query90	1860	150	146	146
query91	153	139	122	122
query92	49	47	42	42
query93	1414	1132	769	769
query94	643	246	213	213
query95	614	441	341	341
query96	842	535	281	281
query97	1010	1005	990	990
query98	146	136	144	136
query99	407	346	306	306
Total cold run time: 178556 ms
Total hot run time: 84745 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.08	0.04	0.04
query3	0.24	0.11	0.10
query4	1.60	0.11	0.10
query5	0.17	0.15	0.15
query6	1.27	0.66	0.68
query7	0.03	0.01	0.00
query8	0.05	0.03	0.03
query9	0.30	0.21	0.21
query10	0.34	0.39	0.35
query11	0.16	0.11	0.11
query12	0.15	0.12	0.12
query13	0.31	0.30	0.30
query14	0.46	0.47	0.44
query15	0.38	0.35	0.35
query16	0.22	0.22	0.22
query17	0.69	0.69	0.71
query18	0.17	0.15	0.16
query19	1.22	1.21	1.15
query20	0.02	0.01	0.01
query21	15.47	0.16	0.13
query22	5.08	0.04	0.04
query23	16.18	0.24	0.10
query24	2.99	0.31	0.28
query25	0.09	0.04	0.03
query26	0.83	0.18	0.12
query27	0.04	0.03	0.02
query28	3.67	0.57	0.27
query29	12.45	3.18	2.57
query30	0.26	0.11	0.12
query31	2.76	0.38	0.17
query32	3.53	0.32	0.22
query33	1.38	1.40	1.55
query34	15.37	2.13	1.73
query35	1.76	1.73	1.66
query36	0.48	0.28	0.29
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.03	0.03
query40	0.11	0.07	0.07
query41	0.08	0.03	0.03
query42	0.03	0.03	0.03
query43	0.03	0.02	0.03
Total cold run time: 90.59 s
Total hot run time: 14.56 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 65.00% (871/1340) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 77.19% (1418/1837) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 60.61% (26742/44120)
Line Coverage 45.01% (272903/606313)
Region Coverage 40.69% (217397/534334)
Branch Coverage 42.17% (100252/237736)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 82.98% (1521/1833) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.86% (32180/42985)
Line Coverage 59.32% (356974/601824)
Region Coverage 55.57% (297404/535183)
Branch Coverage 56.45% (134137/237630)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 66.49% (891/1340) 🎉
Increment coverage report
Complete coverage report

@jacktengg
jacktengg force-pushed the timestamp_ns-split-commit1-cast-and-functions branch from f7b433d to 415fb3c Compare August 15, 2026 16:14
@jacktengg

Copy link
Copy Markdown
Contributor Author

/review

@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Review step was failure (possibly timeout or cancelled)
Workflow run: https://github.com/apache/doris/actions/runs/31894966482

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17562	3040	3038	3038
q2	1893	251	155	155
q3	10455	903	508	508
q4	4666	244	196	196
q5	7689	561	388	388
q6	140	115	91	91
q7	544	515	393	393
q8	9240	971	986	971
q9	3413	2338	2348	2338
q10	6515	851	731	731
q11	456	257	236	236
q12	690	401	335	335
q13	17905	1821	1535	1535
q14	157	146	138	138
q15	q16	457	396	358	358
q17	847	826	791	791
q18	3115	2263	2240	2240
q19	1119	928	745	745
q20	658	520	493	493
q21	5335	1902	1932	1902
q22	340	274	234	234
Total cold run time: 93196 ms
Total hot run time: 17816 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3388	3342	3344	3342
q2	203	213	153	153
q3	2240	2253	2176	2176
q4	1178	1156	869	869
q5	2205	2094	2096	2094
q6	171	125	87	87
q7	1007	920	870	870
q8	1604	1397	1427	1397
q9	3059	3038	2992	2992
q10	1863	1780	1607	1607
q11	355	273	247	247
q12	458	428	334	334
q13	1809	1865	1589	1589
q14	175	172	169	169
q15	q16	390	396	353	353
q17	1047	1035	1032	1032
q18	4913	4394	4759	4394
q19	845	852	867	852
q20	959	960	804	804
q21	3780	3111	3279	3111
q22	403	367	333	333
Total cold run time: 32052 ms
Total hot run time: 28805 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 85488 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 415fb3c96f93f64b9d0f1ca1898e62c6f1e41e35, data reload: false

query5	4235	427	338	338
query6	408	186	168	168
query7	4820	450	271	271
query8	290	129	117	117
query9	8666	2888	2890	2888
query10	401	286	225	225
query11	5380	1023	925	925
query12	123	77	71	71
query13	1206	458	362	362
query14	5963	2003	1859	1859
query14_1	1771	1752	1771	1752
query15	167	110	104	104
query16	905	377	353	353
query17	776	433	368	368
query18	2317	332	226	226
query19	161	141	110	110
query20	71	70	66	66
query21	203	118	101	101
query22	5313	5324	5279	5279
query23	7162	6586	6595	6586
query23_1	6478	6472	6543	6472
query24	7321	1110	796	796
query24_1	800	766	789	766
query25	420	282	235	235
query26	1259	265	164	164
query27	2716	459	281	281
query28	4647	1515	1478	1478
query29	915	443	366	366
query30	281	181	152	152
query31	975	666	628	628
query32	107	53	51	51
query33	504	209	167	167
query34	1006	827	501	501
query35	413	392	330	330
query36	547	561	516	516
query37	125	82	73	73
query38	988	847	807	807
query39	523	548	532	532
query39_1	523	537	495	495
query40	219	122	111	111
query41	53	50	49	49
query42	76	74	70	70
query43	246	250	217	217
query44	1038	568	569	568
query45	107	101	97	97
query46	781	846	530	530
query47	941	950	917	917
query48	317	324	233	233
query49	557	239	192	192
query50	822	310	268	268
query51	7970	8235	8007	8007
query52	71	73	63	63
query53	219	213	162	162
query54	247	198	193	193
query55	82	64	55	55
query56	275	237	230	230
query57	653	644	608	608
query58	238	194	208	194
query59	1147	1135	1008	1008
query60	260	231	221	221
query61	147	141	152	141
query62	345	206	212	206
query63	196	161	159	159
query64	2766	709	546	546
query65	1540	1511	1518	1511
query66	1781	292	222	222
query67	9611	9647	9698	9647
query68	3015	1258	774	774
query69	340	227	195	195
query70	664	581	567	567
query71	298	251	240	240
query72	2363	1755	1650	1650
query73	655	633	338	338
query74	2017	1247	1170	1170
query75	1244	1143	1001	1001
query76	2367	748	556	556
query77	249	258	213	213
query78	5102	4765	4516	4516
query79	1614	855	606	606
query80	1198	417	348	348
query81	468	197	175	175
query82	625	135	109	109
query83	322	250	236	236
query84	319	121	100	100
query85	860	446	387	387
query86	390	170	168	168
query87	990	975	882	882
query88	2822	2131	2157	2131
query89	312	230	210	210
query90	1970	141	147	141
query91	153	147	123	123
query92	50	48	47	47
query93	1404	1150	782	782
query94	635	236	226	226
query95	606	439	374	374
query96	827	586	271	271
query97	1030	1064	1028	1028
query98	141	132	143	132
query99	416	348	303	303
Total cold run time: 178477 ms
Total hot run time: 85488 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.63 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 415fb3c96f93f64b9d0f1ca1898e62c6f1e41e35, data reload: false

query1	0.01	0.00	0.01
query2	0.08	0.03	0.04
query3	0.24	0.11	0.11
query4	1.60	0.10	0.10
query5	0.18	0.15	0.15
query6	1.30	0.68	0.69
query7	0.03	0.01	0.00
query8	0.05	0.03	0.03
query9	0.30	0.21	0.22
query10	0.34	0.34	0.35
query11	0.16	0.11	0.11
query12	0.15	0.13	0.11
query13	0.32	0.30	0.31
query14	0.46	0.46	0.46
query15	0.36	0.34	0.35
query16	0.23	0.22	0.23
query17	0.70	0.67	0.70
query18	0.17	0.17	0.16
query19	1.26	1.15	1.16
query20	0.02	0.01	0.01
query21	15.48	0.16	0.11
query22	5.08	0.05	0.04
query23	16.26	0.25	0.10
query24	3.06	0.32	0.24
query25	0.11	0.04	0.03
query26	0.78	0.16	0.12
query27	0.04	0.04	0.03
query28	3.68	0.55	0.27
query29	12.46	3.18	2.58
query30	0.27	0.12	0.12
query31	2.76	0.38	0.17
query32	3.53	0.31	0.23
query33	1.47	1.52	1.41
query34	15.43	2.19	1.77
query35	1.75	1.71	1.76
query36	0.45	0.30	0.28
query37	0.07	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.02	0.03
query40	0.12	0.08	0.08
query41	0.08	0.03	0.02
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.98 s
Total hot run time: 14.63 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 65.03% (872/1341) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 87.07% (1609/1848) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.85% (32181/42996)
Line Coverage 59.39% (357531/602007)
Region Coverage 55.60% (297615/535266)
Branch Coverage 56.49% (134252/237638)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 66.67% (894/1341) 🎉
Increment coverage report
Complete coverage report

@jacktengg

Copy link
Copy Markdown
Contributor Author

/review

@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Review step was failure (possibly timeout or cancelled)
Workflow run: https://github.com/apache/doris/actions/runs/31945588219

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17369	3166	3137	3137
q2	1900	246	154	154
q3	10193	889	519	519
q4	4660	241	194	194
q5	7749	595	375	375
q6	142	116	91	91
q7	524	498	393	393
q8	9296	982	977	977
q9	3469	2411	2362	2362
q10	6494	899	699	699
q11	454	254	235	235
q12	692	392	336	336
q13	17890	1882	1541	1541
q14	193	149	140	140
q15	q16	447	398	368	368
q17	2479	895	723	723
q18	3057	2272	2229	2229
q19	2445	933	840	840
q20	725	528	464	464
q21	5688	1690	1958	1690
q22	328	276	225	225
Total cold run time: 96194 ms
Total hot run time: 17692 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3556	3487	3444	3444
q2	207	214	155	155
q3	2146	2298	2172	2172
q4	1187	1168	900	900
q5	2183	2098	2097	2097
q6	172	132	84	84
q7	1026	895	814	814
q8	1614	1413	1440	1413
q9	3110	3071	3029	3029
q10	1822	1770	1634	1634
q11	360	271	249	249
q12	459	451	347	347
q13	1811	1841	1564	1564
q14	172	179	158	158
q15	q16	395	396	364	364
q17	1057	1038	1033	1033
q18	4959	4386	4777	4386
q19	856	840	832	832
q20	970	1073	822	822
q21	3749	3070	3266	3070
q22	406	345	320	320
Total cold run time: 32217 ms
Total hot run time: 28887 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 85184 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 96e9fb69bf76c53f89401f9ccebafa9d497fe1e2, data reload: false

query5	4253	414	337	337
query6	399	160	155	155
query7	4881	432	255	255
query8	294	116	111	111
query9	8658	2909	2909	2909
query10	414	254	209	209
query11	5369	1033	925	925
query12	116	72	69	69
query13	1193	457	333	333
query14	5941	1991	1857	1857
query14_1	1775	1749	1755	1749
query15	178	111	105	105
query16	908	408	351	351
query17	769	455	353	353
query18	2339	328	226	226
query19	161	145	110	110
query20	71	67	68	67
query21	213	120	105	105
query22	5239	5275	5190	5190
query23	7225	6679	6587	6587
query23_1	6620	6635	6482	6482
query24	7197	1079	767	767
query24_1	752	793	776	776
query25	415	280	237	237
query26	1259	251	168	168
query27	2725	410	295	295
query28	4589	1506	1512	1506
query29	909	447	339	339
query30	268	178	152	152
query31	968	665	607	607
query32	103	50	55	50
query33	451	213	173	173
query34	998	810	500	500
query35	398	381	344	344
query36	558	531	524	524
query37	123	85	72	72
query38	993	836	820	820
query39	560	526	532	526
query39_1	474	536	517	517
query40	238	121	112	112
query41	53	53	52	52
query42	74	74	74	74
query43	250	253	217	217
query44	1026	579	570	570
query45	109	104	99	99
query46	744	868	536	536
query47	971	968	1013	968
query48	318	340	243	243
query49	557	256	188	188
query50	826	333	262	262
query51	8086	8021	8002	8002
query52	72	78	72	72
query53	217	223	161	161
query54	235	211	189	189
query55	78	58	60	58
query56	258	247	238	238
query57	649	642	617	617
query58	241	221	224	221
query59	1099	1097	980	980
query60	241	201	205	201
query61	108	119	114	114
query62	347	207	169	169
query63	190	156	158	156
query64	2765	662	595	595
query65	1566	1555	1605	1555
query66	1821	308	242	242
query67	9732	9787	9552	9552
query68	2989	1243	800	800
query69	336	218	186	186
query70	630	589	590	589
query71	291	250	241	241
query72	2281	1728	1562	1562
query73	624	606	328	328
query74	1978	1208	1135	1135
query75	1230	1130	1003	1003
query76	2305	750	535	535
query77	241	241	207	207
query78	5196	4735	4463	4463
query79	1206	840	575	575
query80	1195	393	348	348
query81	477	192	173	173
query82	625	135	107	107
query83	311	258	229	229
query84	310	124	107	107
query85	837	440	370	370
query86	387	189	169	169
query87	983	958	899	899
query88	2793	2150	2121	2121
query89	306	227	213	213
query90	1849	140	145	140
query91	157	140	126	126
query92	48	45	42	42
query93	1382	1145	745	745
query94	624	238	228	228
query95	614	441	341	341
query96	816	590	269	269
query97	1047	1060	1041	1041
query98	149	134	133	133
query99	420	352	306	306
Total cold run time: 177648 ms
Total hot run time: 85184 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 16.4 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 96e9fb69bf76c53f89401f9ccebafa9d497fe1e2, data reload: false

query1	0.00	0.00	0.00
query2	0.11	0.06	0.06
query3	0.33	0.20	0.20
query4	1.60	0.19	0.19
query5	0.25	0.23	0.24
query6	1.21	0.39	0.38
query7	0.03	0.01	0.00
query8	0.08	0.05	0.05
query9	0.42	0.27	0.28
query10	0.38	0.37	0.39
query11	0.27	0.15	0.15
query12	0.27	0.16	0.15
query13	0.36	0.37	0.37
query14	0.46	0.47	0.47
query15	0.49	0.40	0.40
query16	0.27	0.29	0.27
query17	0.64	0.68	0.66
query18	0.24	0.24	0.21
query19	1.20	1.15	1.10
query20	0.01	0.02	0.01
query21	15.38	0.28	0.26
query22	4.86	0.11	0.10
query23	15.90	0.39	0.24
query24	2.61	0.47	0.32
query25	0.12	0.08	0.07
query26	0.73	0.21	0.17
query27	0.09	0.08	0.07
query28	3.47	0.60	0.36
query29	12.40	3.29	2.66
query30	0.34	0.18	0.21
query31	2.75	0.42	0.23
query32	3.43	0.37	0.27
query33	1.36	1.55	1.37
query34	15.35	2.42	1.95
query35	1.87	1.86	1.88
query36	0.51	0.38	0.34
query37	0.09	0.08	0.07
query38	0.07	0.06	0.05
query39	0.06	0.04	0.05
query40	0.13	0.11	0.10
query41	0.10	0.06	0.06
query42	0.07	0.05	0.04
query43	0.06	0.05	0.05
Total cold run time: 90.37 s
Total hot run time: 16.4 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 71.62% (805/1124) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 60.39% (26760/44315)
Line Coverage 44.90% (273357/608781)
Region Coverage 40.51% (217695/537365)
Branch Coverage 42.09% (100338/238365)

@jacktengg jacktengg changed the title [feature](timestamp_ns) Support casts and date-time functions [feature](timestamp_ns) Support casts, functions and external tables Aug 16, 2026
@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 86.53% (970/1121) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.82% (32179/43009)
Line Coverage 59.36% (357548/602334)
Region Coverage 55.56% (297593/535622)
Branch Coverage 56.48% (134304/237785)

  ### What problem does this PR solve?

  Issue Number: None

  Related PR: apache#66333

  Problem Summary:

  Doris DATETIME and DATETIMEV2 support at most six fractional-second
  digits. Extending their existing packed civil-time representation to
  nanoseconds would mix incompatible storage representations and semantics.

  Introduce TIMESTAMP_NS as a separate, fixed-precision timestamp type:

  - TIMESTAMP_NS always has nine fractional-second digits and does not accept
    a precision parameter.
  - Values are stored as signed Int64 nanoseconds relative to the Unix epoch.
  - The supported range is
    [1677-09-21 00:12:43.145224192,
     2262-04-11 23:47:16.854775807].
  - TIMESTAMP_NS has no time-zone attribute. UTC is used as the stable mapping
    between its civil-time fields and physical epoch-nanosecond representation.
  - DATETIME(p) and DATETIMEV2(p) retain their existing behavior and continue
    to support only precision 0 through 6.

  Add the new primitive type to Thrift, protobuf, FE type metadata, Nereids,
  BE data types, and cloud schema metadata. Add dedicated TIMESTAMP_NS literal,
  value, column, and SerDe implementations.

  Support the basic end-to-end SQL and storage paths, including:

  - DDL, literals, default values, partitions, buckets, and schema metadata
  - Insert, stream load, partial update, and decoded timestamp input
  - Segment storage, key coding, zone map, bloom filter, and inverted index
  - Comparison, predicates, hashing, grouping, ordering, joins, runtime
    filters, and basic aggregate functions
  - FE literal validation, constant folding, type coercion, and predicate
    simplification
  - MySQL text and prepared-statement binary results, using string-compatible
    output to preserve all nine fractional digits

 Arrow Flight SQL output, ORC OUTFILE, and Java UDF signatures explicitly
  reject TIMESTAMP_NS because those integrations are not supported yet.
  The broader explicit cast matrix and scalar date/time function signatures
  will be implemented in follow-up changes.

  ### Release note

  Add the fixed-precision TIMESTAMP_NS SQL type for nanosecond timestamps.
  TIMESTAMP_NS stores signed Int64 Unix-epoch nanoseconds, supports the range
  from 1677-09-21 00:12:43.145224192 through
  2262-04-11 23:47:16.854775807, and always displays nine fractional digits.

  Existing DATETIME and DATETIMEV2 types remain limited to precision 0 through 6.

  ### Check List (For Author)

  - Test: Unit Test and Regression Test
      - Added BE unit tests for TIMESTAMP_NS values, SerDe, storage indexes,
        hashing, predicates, aggregates, and partitioning
      - Added FE unit tests for types, literals, boundaries, partitions,
        coercion, folding, MySQL output, and unsupported integrations
      - Added regression tests for DDL, predicates, storage, stream load,
        partial/default values, and MySQL prepared-statement output
  - Behavior changed: Yes; adds the TIMESTAMP_NS SQL and storage type without
    changing DATETIME or DATETIMEV2 precision semantics
  - Does this need documentation: Yes; TIMESTAMP_NS syntax, range, storage
    semantics, and current integration limitations require documentation
Issue Number: None

Related PR: None

Problem Summary: TIMESTAMP_NS basic type support did not include the cast matrix or the date-time function surface available to DATETIMEV2. Queries that converted TIMESTAMP_NS values, combined them with other temporal types, or used date arithmetic, extraction, formatting, aggregate, window, and conditional functions could fail during analysis or backend function resolution. This change adds explicit FE signatures and coercion rules together with BE vectorized implementations. Nanoseconds are preserved when the result remains TIMESTAMP_NS, conversions to lower-precision types use existing rounding semantics, and operations that leave the signed epoch-nanosecond domain report an error instead of wrapping.

Support casts and date-time functions for TIMESTAMP_NS.

- Test: Unit Test and Regression test
    - FE unit tests for cast validation, literal conversion, type coercion, and function signatures
    - BE unit tests for casts, scalar functions, conditional expressions, and aggregate/window factories
    - datatype_p0/timestamp_ns regression suites
- Behavior changed: Yes (TIMESTAMP_NS supports casts and date-time functions)
- Does this need documentation: No
Issue Number: None

Related PR: None

Problem Summary: TIMESTAMP_NS external table integration was mixed into the cast and date-time function commit, which made connector and file-format changes difficult to review and test independently. This commit isolates the Iceberg, Paimon, ADBC, JNI scanner, Parquet, and ORC mappings, readers, writers, predicates, unit tests, and regression expectations without changing the combined source tree.

None

- Test: Manual test
    - Verify the two replacement commits reproduce the exact tree of a3b5d8dd6f8dcd43f9ca7960aa1a23c4a04876c8
- Behavior changed: No (commit history was split without changing the combined source tree)
- Does this need documentation: No
Issue Number: None

Related PR: None

Problem Summary: Paimon stores high-precision TIMESTAMP values as unannotated Parquet INT96. FileScannerV2 inferred that encoding as DATETIMEV2(6), so TIMESTAMP(7..9) lost trailing nanoseconds before conversion to TIMESTAMP_NS. Carry the Paimon precision semantic through the schema history and V2 projection metadata, and decode matching Parquet timestamps directly as TIMESTAMP_NS without changing ORC or lower-precision timestamp semantics.

Fix nanosecond precision loss when native scanning Paimon Parquet TIMESTAMP(7..9) columns.

- Test: Regression test and Unit Test
    - Regression test: external_table_p0/paimon/paimon_timestamp_types
    - Unit Test: PaimonScanPlanProviderTest and targeted BE format_v2 tests
- Behavior changed: Yes. Native Paimon Parquet scans preserve nanoseconds for TIMESTAMP(7..9).
- Does this need documentation: No
@jacktengg
jacktengg force-pushed the timestamp_ns-split-commit1-cast-and-functions branch from 96e9fb6 to f96babd Compare August 17, 2026 09:50
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.

2 participants