Skip to content

[feature](timestamp_ns) Add end-to-end TIMESTAMP_NS support - #66761

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

[feature](timestamp_ns) Add end-to-end TIMESTAMP_NS support#66761
jacktengg wants to merge 29 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

Docs: apache/doris-website#4091

Problem Summary:
Doris DATETIME only support at most six fractional digits, it's not sufficient for event times, traces, etc which require higher precision of sub-seconds.

Introduce TIMESTAMP_NS as a separate fixed-scale SQL type backed by signed Int64 Unix-epoch nanoseconds. It always has scale 9 and supports values from 1677-09-21 00:12:43.145224192 through 2262-04-11 23:47:16.854775807. Wire the type through Thrift and protobuf metadata, the FE catalog and Nereids, BE columns and SerDe, storage and indexes, result protocols, JNI and Java UDF transport, complex and VARIANT types, and schema metadata.

Add exact casts, comparisons, type inference, and constant folding across date-like types while preserving nanoseconds and rejecting partial or precision-losing implicit conversions. Add timestamp-aware scalar and calendar functions, aggregation, joins and ASOF joins, scan predicates, runtime filters, partition pruning, query-cache normalization, automatic partitions, and MTMV roll-up. Keep FE folding and BE runtime behavior consistent at signed endpoints, leap years, DST gaps, calendar-clamped boundaries, and fractional formatting and rounding boundaries.

Keep existing DATETIME and DATETIMEV2 scale semantics unchanged. FROM_UNIXTIME retains a DECIMAL64 microsecond path for scale 0 through 6 and uses the DECIMAL128 nanosecond path only for scale 7 through 9. The %f formatter rounds half-up to microseconds with second carry, while %n preserves the nanosecond fraction.

  • Test: Unit Test and Regression Test
    • Added targeted BE unit coverage for TIMESTAMP_NS values, casts, functions, SerDe, predicates, aggregates, joins, and compatibility paths
    • Added targeted FE unit coverage for literals, casts, constant folding, type inference, partitions, query-cache and MTMV boundaries, and statement-time semantics
    • Added regression coverage under datatype_p0/timestamp_ns and focused MTMV and Java UDF suites
    • Built FE and BE with the standard build scripts
  • Behavior changed: Yes. Adds TIMESTAMP_NS and nanosecond function semantics without changing the scale limits of DATETIME or DATETIMEV2.
  • Does this need documentation: Yes. Document TIMESTAMP_NS syntax, range, casts and coercion rules, function behavior, and integration support.

Release note

Add TIMESTAMP_NS, a fixed-scale nanosecond timestamp type stored as signed Unix-epoch nanoseconds. It supports SQL literals, casts, date/time functions, storage and indexes, partitions, joins, aggregates, complex types, Java UDF/JNI transport, and FE constant folding and type inference. Existing DATETIME and DATETIMEV2 types remain limited to scale 0 through 6.

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

BE Regression && UT Coverage Report

Increment line coverage 76.30% (1275/1671) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 65.62% (29831/45463)
Line Coverage 50.37% (321332/637916)
Region Coverage 46.18% (263790/571231)
Branch Coverage 47.33% (121695/257102)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 73.91% (1725/2334) 🎉
Increment coverage report
Complete coverage report

Issue Number: None

Related PR: apache#66761

Problem Summary: TIMESTAMP_NS had basic Arrow round-trip coverage but lacked complete time-unit boundary checks, nested FE schema checks, and an end-to-end Arrow Flight SQL regression. Add exact conversion and overflow tests, nested schema assertions, and Flight queries for nanosecond boundary values under multiple session time zones.

None

- Test: Unit Test and Regression test
    - `./run-fe-ut.sh --run org.apache.doris.service.arrowflight.FlightSqlSchemaHelperArrowTypeTest`
    - `./run-be-ut.sh --run --filter=DataTypeSerDeArrowTest.TimeStampNsArrowRoundTrip:DataTypeSerDeArrowTest.TimeStampNsArrowUnitConversion -j 16`
    - `./run-regression-test.sh --run -d arrow_flight_sql_p0 -s test_select`
- Behavior changed: No
- Does this need documentation: No
@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 69.92% (1632/2334) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17580	3056	3069	3056
q2	2095	257	242	242
q3	10242	891	519	519
q4	4672	250	201	201
q5	7678	564	388	388
q6	140	117	94	94
q7	529	496	395	395
q8	9235	874	958	874
q9	3479	2412	2441	2412
q10	6540	869	730	730
q11	400	202	187	187
q12	622	269	199	199
q13	18148	1557	1187	1187
q14	186	151	140	140
q15	q16	443	413	374	374
q17	1372	866	755	755
q18	3080	2300	2300	2300
q19	1113	885	758	758
q20	404	285	201	201
q21	5266	1684	1875	1684
q22	333	277	235	235
Total cold run time: 93557 ms
Total hot run time: 16931 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3463	3385	3355	3355
q2	517	403	386	386
q3	2324	2364	2206	2206
q4	1226	1184	923	923
q5	2193	2152	2134	2134
q6	168	120	89	89
q7	1082	981	877	877
q8	1637	1434	1438	1434
q9	3218	3165	3205	3165
q10	1899	1835	1661	1661
q11	368	275	263	263
q12	463	446	356	356
q13	1510	1545	1184	1184
q14	170	176	161	161
q15	q16	412	405	370	370
q17	3670	3362	3271	3271
q18	4893	4562	5064	4562
q19	968	893	849	849
q20	1021	994	837	837
q21	3961	3261	3274	3261
q22	407	344	333	333
Total cold run time: 35570 ms
Total hot run time: 31677 ms

@hello-stephen

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

query5	4270	427	347	347
query6	397	141	127	127
query7	4903	396	236	236
query8	300	129	130	129
query9	8694	3021	3028	3021
query10	395	240	187	187
query11	5367	1043	933	933
query12	122	71	71	71
query13	1208	445	330	330
query14	6046	2272	2143	2143
query14_1	2053	2044	2029	2029
query15	173	128	118	118
query16	951	403	379	379
query17	832	491	397	397
query18	2368	344	273	273
query19	174	144	115	115
query20	88	75	74	74
query21	216	114	99	99
query22	5551	5395	5414	5395
query23	6932	6389	6381	6381
query23_1	6397	6390	6248	6248
query24	7296	1092	795	795
query24_1	778	788	813	788
query25	449	325	271	271
query26	1253	248	134	134
query27	2759	429	267	267
query28	4652	1546	1557	1546
query29	951	466	369	369
query30	248	158	132	132
query31	856	417	336	336
query32	133	83	78	78
query33	481	225	171	171
query34	1029	868	497	497
query35	419	402	349	349
query36	600	596	551	551
query37	124	81	71	71
query38	1006	860	817	817
query39	517	492	487	487
query39_1	474	487	477	477
query40	198	95	84	84
query41	56	53	53	53
query42	76	74	74	74
query43	245	244	217	217
query44	1023	556	557	556
query45	106	110	101	101
query46	795	833	536	536
query47	772	799	718	718
query48	318	318	232	232
query49	539	237	195	195
query50	774	269	196	196
query51	8486	8202	8208	8202
query52	67	69	58	58
query53	196	193	157	157
query54	217	167	168	167
query55	78	59	57	57
query56	201	169	157	157
query57	738	669	675	669
query58	194	170	160	160
query59	1237	1232	1120	1120
query60	236	175	195	175
query61	107	115	124	115
query62	346	200	175	175
query63	168	140	141	140
query64	2762	712	648	648
query65	1645	1598	1598	1598
query66	1765	266	209	209
query67	9774	9978	9965	9965
query68	2779	1238	762	762
query69	346	217	208	208
query70	656	650	620	620
query71	254	175	168	168
query72	2385	1804	1626	1626
query73	632	597	335	335
query74	1567	1238	1144	1144
query75	1182	1138	982	982
query76	2314	754	520	520
query77	265	276	207	207
query78	4044	3635	3192	3192
query79	2341	836	606	606
query80	1608	339	284	284
query81	493	161	137	137
query82	638	132	99	99
query83	290	206	199	199
query84	295	112	91	91
query85	811	367	317	317
query86	389	169	176	169
query87	1017	1003	906	906
query88	2808	2128	2130	2128
query89	278	197	178	178
query90	1978	137	135	135
query91	135	123	106	106
query92	75	76	69	69
query93	1439	1144	679	679
query94	648	271	238	238
query95	560	256	239	239
query96	820	588	283	283
query97	1133	1060	1036	1036
query98	149	139	134	134
query99	427	346	310	310
Total cold run time: 178726 ms
Total hot run time: 84247 ms

@hello-stephen

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

query1	0.01	0.00	0.00
query2	0.08	0.04	0.04
query3	0.25	0.12	0.11
query4	1.60	0.09	0.10
query5	0.18	0.16	0.15
query6	1.24	0.69	0.69
query7	0.03	0.01	0.01
query8	0.05	0.03	0.02
query9	0.29	0.23	0.22
query10	0.35	0.35	0.36
query11	0.16	0.12	0.11
query12	0.15	0.12	0.12
query13	0.31	0.32	0.33
query14	0.46	0.46	0.44
query15	0.37	0.36	0.36
query16	0.23	0.23	0.24
query17	0.73	0.75	0.70
query18	0.18	0.17	0.16
query19	1.25	1.24	1.18
query20	0.01	0.02	0.01
query21	15.44	0.15	0.12
query22	5.08	0.04	0.04
query23	16.18	0.26	0.10
query24	2.96	0.32	0.26
query25	0.11	0.04	0.03
query26	0.78	0.16	0.13
query27	0.04	0.03	0.02
query28	3.69	0.60	0.29
query29	12.42	3.20	2.56
query30	0.25	0.11	0.13
query31	2.76	0.36	0.17
query32	3.52	0.33	0.24
query33	1.54	1.44	1.51
query34	15.39	2.22	1.82
query35	1.79	1.81	1.78
query36	0.47	0.30	0.30
query37	0.07	0.04	0.04
query38	0.05	0.03	0.03
query39	0.04	0.02	0.03
query40	0.12	0.09	0.07
query41	0.07	0.03	0.02
query42	0.04	0.02	0.02
query43	0.03	0.03	0.02
Total cold run time: 90.77 s
Total hot run time: 14.94 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 93.98% (1576/1677) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.33% (34716/45480)
Line Coverage 61.33% (391316/638091)
Region Coverage 57.44% (328300/571519)
Branch Coverage 58.30% (149933/257182)

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: TIMESTAMP_NS delete-condition validation duplicated the date-time validation path with a type-specific parser. The shared validator was limited to six fractional digits, so it could not be reused for the fixed nine-digit TIMESTAMP_NS scale. Generalize fractional-second validation through scale 9 and route TIMESTAMP_NS through the same validation branch as DATETIMEV2 while preserving the DATETIMEV2 six-digit limit.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter=DeleteConditionValueTest.ValidDatetimeSupportsNanosecondScale -j 32
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: TIMESTAMP_NS index tests did not prove that default V3 inverted indexes and synchronous rollup indexes were selected, and lacked NULL-path coverage for ZoneMap, Bloom Filter, V2 inverted indexes, and SNII. Add BE writer/reader checks for NULL metadata and bitmaps, add end-to-end profile counter assertions for V3, SNII, explicit Bloom Filter, and rollup rewrite, and fix unsupported NGRAM_BF and ANN behavior with negative DDL tests.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: targeted TIMESTAMP_NS Bloom Filter, V2 inverted index, and ZoneMap BE tests
    - Regression test: test_timestamp_ns_index and test_timestamp_ns_mv
    - Static checks: check-format, check-build-hygiene, and git diff --check
    - Clang-tidy: attempted, but the local GCC 15 toolchain could not resolve stddef.h while parsing the test translation units
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: TIMESTAMP_NS numeric casts converted rows directly in the cast implementation instead of using the strict and non-strict SerDe batch paths used by DATETIMEV2. TIMESTAMP_NS JSONB and textual number serialization also bypassed CastToString helpers, and no SQL regression directly covered legacy JSONB write/read round trips. Add the missing integer, floating-point, and decimal batch SerDe interfaces for both cast modes, route numeric casts through them, centralize string conversion, and add unit and regression coverage.

### Release note

None

### Check List (For Author)

- Test: Regression test / Unit Test / Build
    - `./run-be-ut.sh --run --filter=DatelikeSerDeBatchTest.timestamp_ns_*:DataTypeTimeStampNsTest.SerDeStrictBatchJsonJsonbMysqlAndBinaryField -j 24`
    - `./run-regression-test.sh --run -d datatype_p0/timestamp_ns -s test_timestamp_ns_cast`
    - `./run-regression-test.sh --run -d datatype_p0/timestamp_ns -s test_timestamp_ns_jsonb`
    - `./build.sh --be -j 24`
- Behavior changed: No; the conversion is routed through shared helpers and batch SerDe interfaces with equivalent strict/non-strict semantics.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: TIMESTAMP_NS predicate creator branches for comparison, IN, NOT IN, and runtime Bloom Filter lacked complete direct unit-test coverage. Add focused tests that instantiate each factory and verify the generated predicate type and filtering behavior.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter=PredicateCreatorTest.*:ScanNormalizePredicate.TimestampNsInPredicateBuildsPointScanKeys -j 8
- Behavior changed: No
- Does this need documentation: No
@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.06% (2053/2630)
Line Coverage 65.77% (37492/57006)
Region Coverage 52.99% (34974/65998)
Branch Coverage 56.42% (11233/19910)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 77.03% (1288/1672) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.00% (29587/46963)
Line Coverage 47.95% (309549/645559)
Region Coverage 43.48% (249493/573782)
Branch Coverage 45.08% (116287/257929)

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: TimeStampNsValue exposed unused arithmetic, date-difference, and seeded-hash helpers while several retained calendar, difference, formatting, interval, and truncation interfaces lacked direct unit-test coverage. Remove the unused public interfaces, keep the internally required time-difference helper private, and add boundary-focused tests for every retained behavior.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter='DataTypeTimeStampNsTest.*' -j 8
    - build-support/check-build-hygiene.sh
    - build-support/check-format.sh with clang-format 16
    - build-support/run-clang-tidy.sh --build-dir be/ut_build_ASAN with clang-tidy 16
- Behavior changed: No; unused C++ interfaces were removed and retained behavior was not changed
- Does this need documentation: No
@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 77.71% (2053/2642)
Line Coverage 65.65% (37475/57080)
Region Coverage 52.91% (34954/66057)
Branch Coverage 56.34% (11236/19942)

@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 77.71% (2053/2642)
Line Coverage 65.64% (37469/57080)
Region Coverage 52.85% (34911/66057)
Branch Coverage 56.28% (11223/19942)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	16626	3051	3042	3042
q2	2090	265	251	251
q3	9942	897	541	541
q4	4656	245	206	206
q5	7786	568	392	392
q6	148	116	98	98
q7	549	513	387	387
q8	9361	855	893	855
q9	3541	2418	2426	2418
q10	6524	899	729	729
q11	394	197	179	179
q12	615	260	198	198
q13	18134	1552	1162	1162
q14	171	153	142	142
q15	q16	433	408	373	373
q17	1290	868	819	819
q18	3139	2308	2321	2308
q19	1131	915	807	807
q20	376	283	198	198
q21	5277	1773	1767	1767
q22	337	269	231	231
Total cold run time: 92520 ms
Total hot run time: 17103 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3358	3324	3316	3316
q2	509	399	364	364
q3	2267	2378	2258	2258
q4	1223	1199	893	893
q5	2229	2148	2147	2147
q6	164	120	87	87
q7	1016	926	865	865
q8	1584	1398	1424	1398
q9	3239	3213	3190	3190
q10	1908	1827	1666	1666
q11	360	273	264	264
q12	448	437	350	350
q13	1488	1535	1140	1140
q14	168	168	167	167
q15	q16	394	398	361	361
q17	3667	3343	3331	3331
q18	4940	4560	4878	4560
q19	868	931	864	864
q20	1016	982	849	849
q21	3843	3264	3181	3181
q22	401	341	333	333
Total cold run time: 35090 ms
Total hot run time: 31584 ms

@hello-stephen

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

query5	4280	433	353	353
query6	375	136	129	129
query7	4916	415	244	244
query8	296	129	121	121
query9	8711	2904	2869	2869
query10	382	209	190	190
query11	5374	1068	953	953
query12	123	73	79	73
query13	1210	433	327	327
query14	6094	2306	2183	2183
query14_1	2133	2081	2074	2074
query15	172	125	116	116
query16	928	387	329	329
query17	805	471	383	383
query18	2345	334	239	239
query19	167	143	124	124
query20	90	72	69	69
query21	197	102	86	86
query22	5478	5483	5384	5384
query23	6935	6265	6237	6237
query23_1	6267	6152	6235	6152
query24	7205	1120	766	766
query24_1	786	815	815	815
query25	439	318	266	266
query26	1230	254	133	133
query27	2762	422	260	260
query28	4601	1521	1513	1513
query29	945	482	367	367
query30	245	159	134	134
query31	825	428	341	341
query32	126	76	73	73
query33	462	231	183	183
query34	992	834	481	481
query35	447	417	365	365
query36	575	569	521	521
query37	122	83	74	74
query38	1021	869	850	850
query39	508	466	462	462
query39_1	456	464	451	451
query40	215	97	88	88
query41	59	56	56	56
query42	77	74	77	74
query43	245	247	217	217
query44	1020	565	554	554
query45	113	110	107	107
query46	768	903	571	571
query47	801	769	760	760
query48	320	356	235	235
query49	525	272	197	197
query50	756	262	204	204
query51	8095	8008	8001	8001
query52	66	67	60	60
query53	192	228	164	164
query54	219	168	156	156
query55	74	59	55	55
query56	192	188	153	153
query57	733	674	678	674
query58	207	166	158	158
query59	1250	1264	1146	1146
query60	261	193	157	157
query61	123	117	125	117
query62	334	207	179	179
query63	173	154	158	154
query64	2772	753	677	677
query65	1703	1688	1679	1679
query66	1780	271	219	219
query67	9851	10194	9881	9881
query68	3037	1244	789	789
query69	348	233	203	203
query70	677	613	626	613
query71	261	181	170	170
query72	2366	1364	1604	1364
query73	637	580	350	350
query74	2019	1304	1160	1160
query75	1255	1159	991	991
query76	2280	759	529	529
query77	258	267	216	216
query78	4155	3902	3354	3354
query79	1221	849	564	564
query80	1198	321	271	271
query81	481	157	136	136
query82	614	127	96	96
query83	278	219	197	197
query84	293	111	91	91
query85	803	367	292	292
query86	394	179	174	174
query87	1114	981	907	907
query88	2789	2113	2115	2113
query89	281	202	180	180
query90	1968	136	125	125
query91	134	129	102	102
query92	76	71	73	71
query93	1373	1050	695	695
query94	616	247	194	194
query95	536	261	325	261
query96	860	553	281	281
query97	1086	1111	1036	1036
query98	142	137	134	134
query99	441	345	322	322
Total cold run time: 177363 ms
Total hot run time: 83651 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.08	0.04	0.04
query3	0.25	0.10	0.11
query4	1.62	0.09	0.10
query5	0.17	0.15	0.16
query6	1.29	0.70	0.68
query7	0.03	0.00	0.01
query8	0.04	0.03	0.03
query9	0.29	0.21	0.21
query10	0.34	0.33	0.34
query11	0.17	0.12	0.12
query12	0.15	0.12	0.12
query13	0.30	0.31	0.31
query14	0.46	0.46	0.46
query15	0.36	0.36	0.36
query16	0.24	0.22	0.23
query17	0.69	0.68	0.70
query18	0.19	0.17	0.17
query19	1.19	1.19	1.11
query20	0.01	0.01	0.00
query21	15.43	0.16	0.11
query22	5.05	0.05	0.04
query23	16.16	0.25	0.10
query24	3.01	0.32	0.29
query25	0.11	0.03	0.02
query26	0.85	0.17	0.13
query27	0.03	0.03	0.03
query28	3.71	0.58	0.28
query29	12.43	3.20	2.61
query30	0.25	0.11	0.12
query31	2.75	0.36	0.18
query32	3.52	0.31	0.23
query33	1.52	1.50	1.50
query34	15.37	2.20	1.77
query35	1.78	1.73	1.76
query36	0.46	0.29	0.29
query37	0.06	0.04	0.04
query38	0.04	0.03	0.02
query39	0.04	0.02	0.03
query40	0.11	0.08	0.07
query41	0.07	0.03	0.02
query42	0.03	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.68 s
Total hot run time: 14.82 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 69.92% (1632/2334) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 70.39% (1697/2411) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 70.28% (1698/2416) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 71.44% (1726/2416) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 78.17% (1300/1663) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.05% (29628/46988)
Line Coverage 48.03% (310223/645878)
Region Coverage 43.53% (249896/574126)
Branch Coverage 45.15% (116532/258099)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 94.50% (1564/1655) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.28% (34715/45512)
Line Coverage 61.23% (390965/638501)
Region Coverage 57.26% (327474/571922)
Branch Coverage 58.16% (149680/257360)

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