[feature](timestamp_ns) Support casts and date-time functions - #66761
[feature](timestamp_ns) Support casts and date-time functions#66761jacktengg wants to merge 3 commits into
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
### 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
a75a76c to
f7b433d
Compare
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 17603 ms |
TPC-DS: Total hot run time: 84745 ms |
ClickBench: Total hot run time: 14.56 s |
FE UT Coverage ReportIncrement line coverage |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
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
### What problem does this PR solve?
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.
### Release note
None
### Check List (For Author)
- 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
f7b433d to
415fb3c
Compare
|
/review |
|
run buildall |
|
Codex automated review failed and did not complete. Error: Review step was failure (possibly timeout or cancelled) Please inspect the workflow logs and rerun the review after the underlying issue is resolved. |
TPC-H: Total hot run time: 17816 ms |
TPC-DS: Total hot run time: 85488 ms |
ClickBench: Total hot run time: 14.63 s |
FE UT Coverage ReportIncrement line coverage |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)