diff --git a/docs/admin-manual/cluster-management/time-zone.md b/docs/admin-manual/cluster-management/time-zone.md index 9e2c244578c24..e59ea1963804c 100644 --- a/docs/admin-manual/cluster-management/time-zone.md +++ b/docs/admin-manual/cluster-management/time-zone.md @@ -93,7 +93,7 @@ Because of implementation differences, some other formats are currently supporte The time zone affects the values returned by time functions such as `NOW()` and `CURTIME()`, as well as the time values shown in `SHOW LOAD` and `SHOW BACKENDS`. -However, it does **not** affect the `LESS THAN` values of time-typed partition columns in `CREATE TABLE`, and it does not affect the displayed values of data stored as `DATE` or `DATETIME` types. +However, it does **not** affect the `LESS THAN` values of time-typed partition columns in `CREATE TABLE`, and it does not affect the displayed values of data stored as `DATE`, `DATETIME`, or `TIMESTAMP_NS` types. Functions affected by the time zone: @@ -107,9 +107,9 @@ Functions affected by the time zone: ### Effect on Time Types -#### DATE / DATETIME Types +#### DATE / DATETIME / TIMESTAMP_NS Types -For the `DATE` and `DATETIME` types, time zone conversion is supported during data ingestion: +For the `DATE`, `DATETIME`, and `TIMESTAMP_NS` types, time zone conversion is supported during data ingestion. `TIMESTAMP_NS` follows the same time-zone-naive storage rule as `DATETIME`, while preserving nine fractional-second digits: - **Data with time zone**: For example, given `2020-12-12 12:12:12+08:00` and a Stream Load header `timezone` of `+00:00`, the actual value stored in Doris is `2020-12-12 04:12:12`. - **Data without time zone**: For example, `2020-12-12 12:12:12` is treated as an absolute time, and no conversion occurs. @@ -164,7 +164,7 @@ Time zone issues involve three main factors: 2. **Ingestion time zone**: the header `timezone` specified during Stream Load, Broker Load, and similar ingestion methods. 3. **Data time zone**: the time-zone literal in the data (for example, the `+08:00` in `2023-12-12 08:00:00+08:00`). -Doris currently supports ingesting data from any time zone into Doris. Because Doris time types such as `DATETIME` do not carry time zone information internally and the stored data does not change with the time zone after ingestion, time data ingested into Doris falls into two categories: +Doris currently supports ingesting data from any time zone into Doris. Because time types such as `DATETIME` and `TIMESTAMP_NS` do not carry time zone information internally and the stored data does not change with the time zone after ingestion, time data ingested into Doris falls into two categories: 1. **Absolute time** @@ -295,7 +295,7 @@ After all the above operations are completed on the BE machine, **the correspond ### Q: After changing `time_zone`, the query results for existing data change unexpectedly? -Types such as `DATETIME` do not carry time zone information internally, and changing the cluster time zone after ingestion does not change the stored values. Confirm the cluster time zone before use, set `time_zone`, and do not change it afterward. +Types such as `DATETIME` and `TIMESTAMP_NS` do not carry time zone information internally, and changing the cluster time zone after ingestion does not change the stored values. Confirm the cluster time zone before use, set `time_zone`, and do not change it afterward. ### Q: The time offset of Stream Load ingested data does not match expectations? diff --git a/docs/data-operate/import/import-way/stream-load-manual.md b/docs/data-operate/import/import-way/stream-load-manual.md index b5761c06c0bb2..e23f686160703 100644 --- a/docs/data-operate/import/import-way/stream-load-manual.md +++ b/docs/data-operate/import/import-way/stream-load-manual.md @@ -511,7 +511,7 @@ curl --location-trusted -u : \ ### Specify the import time zone -The `DATETIME`-related types represent only absolute points in time and do not contain time-zone information; they do not change with the Doris system time zone. Therefore, time-zone-aware data is handled in a unified way during import: it is converted to data in a specified target time zone. In the Doris system, the time zone is the one represented by the session variable `time_zone`. +Time-zone-naive types such as `DATETIME` and `TIMESTAMP_NS` do not contain time-zone information, and their stored values do not change with the Doris system time zone. Therefore, time-zone-aware input is converted to a specified target time zone during import and then stored without a time zone. In Doris, the target time zone is represented by the session variable `time_zone`. In imports, the target time zone is specified by the `timezone` parameter. This variable replaces the session variable `time_zone` when time-zone conversions occur and when time-zone-sensitive functions are evaluated. Therefore, unless there are special circumstances, the `timezone` setting in the import transaction should match the current Doris cluster's `time_zone`. This means all time data with time zones is converted to that time zone. diff --git a/docs/data-operate/update/multi-stream-update-for-unique-model.md b/docs/data-operate/update/multi-stream-update-for-unique-model.md index a333fea57c9a8..ccb0cf8174a1b 100644 --- a/docs/data-operate/update/multi-stream-update-for-unique-model.md +++ b/docs/data-operate/update/multi-stream-update-for-unique-model.md @@ -78,7 +78,7 @@ PROPERTIES ( ); ``` -> Supported types for Sequence columns: integer types, `DATE`, and `DATETIME`. **The type cannot be changed after the column is created.** +> Supported types for Sequence columns: integer types, `DATE`, `DATETIME`, and `TIMESTAMP_NS`. **The type cannot be changed after the column is created.** After creation, the table schema is as follows: @@ -304,7 +304,7 @@ When using Sequence Mapping, note the following constraints: | Category | Constraint | | --- | --- | | **Table creation configuration** | `light_schema_change` must be enabled. If the `sequence_mapping` property is not declared at table creation, it cannot be enabled later. | -| **Column types** | Sequence columns only support integer types and time types (`DATE`, `DATETIME`), and the type cannot be changed after creation. | +| **Column types** | Sequence columns only support integer types and time types (`DATE`, `DATETIME`, `TIMESTAMP_NS`), and the type cannot be changed after creation. | | **Column roles** | Neither Sequence columns nor mapped columns can be Key columns. All non-Key columns must be mapped to a Sequence column. | | **Mapping relationships** | Mapped columns of different Sequence columns **cannot overlap** (for example, `d` cannot be mapped to both `s1` and `s2`). After a mapping is established, **it cannot be modified** (for example, a column already mapped to `s1` cannot be remapped to `s2`). | | **DDL limitations** | Column renaming is not supported. Rollup creation is not supported. | diff --git a/docs/data-operate/update/unique-update-concurrent-control.md b/docs/data-operate/update/unique-update-concurrent-control.md index 34a4f42bdfa54..858a11d3e549d 100644 --- a/docs/data-operate/update/unique-update-concurrent-control.md +++ b/docs/data-operate/update/unique-update-concurrent-control.md @@ -88,7 +88,7 @@ The two properties differ as follows: | `function_column.sequence_col` | Maps the Sequence column to an existing column in the table | Yes | | `function_column.sequence_type` | Specifies only the type of the Sequence column, stored in a hidden column | No | -Supported column types: integer types, `DATE`, and `DATETIME`. **The column type cannot be changed once the table is created.** +Supported column types: integer types, `DATE`, `DATETIME`, and `TIMESTAMP_NS`. **The column type cannot be changed once the table is created.** ### Usage Example diff --git a/docs/key-features/inverted-index.mdx b/docs/key-features/inverted-index.mdx index d1a480a24258c..47f9533955db3 100644 --- a/docs/key-features/inverted-index.mdx +++ b/docs/key-features/inverted-index.mdx @@ -39,7 +39,7 @@ The Apache Doris inverted index handles all three with the same DDL. The Apache Doris inverted index is a column-level secondary index that maps each value, or each tokenized term for text columns, to the set of row IDs that contain it. It is built on top of [CLucene](https://github.com/apache/doris-thirdparty/tree/clucene), a C++ port of Lucene, and is fully integrated with Apache Doris columnar storage and vectorized execution. -An inverted index is declared in DDL with `INDEX () USING INVERTED [PROPERTIES(...)]`. Supported column types include the integer family, `DECIMAL`, `DATE`, `DATETIME`, `IPV4`, `IPV6`, `CHAR`/`VARCHAR`/`STRING`, and `ARRAY` of those. For text columns you can attach a `parser` to control tokenization. +An inverted index is declared in DDL with `INDEX () USING INVERTED [PROPERTIES(...)]`. Supported column types include the integer family, `DECIMAL`, `DATE`, `DATETIME`, `TIMESTAMP_NS`, `IPV4`, `IPV6`, `CHAR`/`VARCHAR`/`STRING`, and `ARRAY` of those. For text columns you can attach a `parser` to control tokenization. **Key terms** diff --git a/docs/key-features/unique-key.mdx b/docs/key-features/unique-key.mdx index 777999a5fc112..074c7c8542e37 100644 --- a/docs/key-features/unique-key.mdx +++ b/docs/key-features/unique-key.mdx @@ -66,7 +66,7 @@ Take an upsert against a Unique Key MoW table. 1. **Buffer the batch.** BEs collect the incoming rows in a memtable and sort them by key. 2. **Look up each key.** For every key in the batch, the BE consults the per-segment primary-key index (one short read per key) to find any existing rowset and row ID. The index is a sorted, paginated structure built when each segment flushed, conceptually similar to a RocksDB partitioned index. 3. **Mark the old rows.** Each affected rowset gets the old row IDs flipped on in its delete bitmap. The bitmap is per `(rowset_id, segment_id, version)` and the old data stays on disk until compaction reclaims it. -4. **Resolve order with the sequence column.** If `function_column.sequence_col` is set, MoW compares the incoming row's sequence value against the current row's `__DORIS_SEQUENCE_COL__`. The larger value wins. Equal values fall back to load order. The sequence type must be an integer or `DATE`/`DATETIME`. +4. **Resolve order with the sequence column.** If `function_column.sequence_col` is set, MoW compares the incoming row's sequence value against the current row's `__DORIS_SEQUENCE_COL__`. The larger value wins. Equal values fall back to load order. The sequence type must be an integer or `DATE`/`DATETIME`/`TIMESTAMP_NS`. 5. **Publish the new rowset.** The transaction commits, the new version becomes visible, and queries from that point on filter through the merged delete bitmap. No version-merging step at read time. `DELETE FROM ... WHERE` follows the same flow without the new rowset. Partial updates add one step: before writing, the BE reads the unmodified columns for each key so it can store a complete row. diff --git a/docs/query-acceleration/optimization-technology-principle/statistics.md b/docs/query-acceleration/optimization-technology-principle/statistics.md index 3e7a6deffafe9..59658b6b603ba 100644 --- a/docs/query-acceleration/optimization-technology-principle/statistics.md +++ b/docs/query-acceleration/optimization-technology-principle/statistics.md @@ -43,7 +43,7 @@ Doris collects statistics per column at the table level, including the following | `max` | Maximum value | | `null_count` | Number of null values | -**Supported column types**: BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DATE, DATETIME, STRING, VARCHAR, TEXT. +**Supported column types**: BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DATE, DATETIME, TIMESTAMP_NS, STRING, VARCHAR, TEXT. **Not supported (automatically skipped)**: JSONB, VARIANT, MAP, STRUCT, ARRAY, HLL, BITMAP, TIME, TIMEV2, VARBINARY. diff --git a/docs/query-data/asof-join.md b/docs/query-data/asof-join.md index 72fc421d6a157..5f6bbff5d90d6 100644 --- a/docs/query-data/asof-join.md +++ b/docs/query-data/asof-join.md @@ -64,7 +64,7 @@ Key points: | --- | --- | --- | | `left_table` | Yes | The left table (probe table). Every row in this table is evaluated. | | `right_table` | Yes | The right table (build table). Used to look up the closest match. | -| `MATCH_CONDITION` | Yes | Defines the nearest-neighbor matching rule. Each side must reference a column from the corresponding table, and both columns must be of type `DATEV2`, `DATETIMEV2`, or `TIMESTAMPTZ`. Expressions are allowed. Supported operators: `>=`, `>`, `<=`, `<`. | +| `MATCH_CONDITION` | Yes | Defines the nearest-neighbor matching rule. Each side must reference a column from the corresponding table, and both columns must be of type `DATEV2`, `DATETIMEV2`, `TIMESTAMP_NS`, or `TIMESTAMPTZ`. Expressions are allowed. Supported operators: `>=`, `>`, `<=`, `<`. | | `ON` / `USING` clause | Yes | Defines one or more equi-keys used as grouping keys. Matching is performed only within the same group. `ON` supports one or more equality (`=`) conditions and expressions (such as `SUBSTRING(l.code, 1, 3) = r.prefix`). `USING` supports one or more columns with the same name. | ## Matching Rules @@ -82,7 +82,7 @@ The matching direction is determined by the comparison operator in `MATCH_CONDIT Pay special attention to the following rules: -1. The columns in `MATCH_CONDITION` must be of type `DATEV2`, `DATETIMEV2`, or `TIMESTAMPTZ`. +1. The columns in `MATCH_CONDITION` must be of type `DATEV2`, `DATETIMEV2`, `TIMESTAMP_NS`, or `TIMESTAMPTZ`. 2. Expressions are allowed inside `MATCH_CONDITION`, for example `MATCH_CONDITION(l.ts >= r.ts + INTERVAL 1 HOUR)` or `MATCH_CONDITION(l.ts >= DATE_ADD(r.ts, INTERVAL 3 HOUR))`. 3. The equi-key clause can be written as `ON` or `USING`. When using `ON`, only equality (`=`) conditions joined by `AND` are allowed. Inequality conditions (such as `>`, `OR`) and literal comparisons (such as `l.grp = 1`) are not allowed in the `ON` clause. 4. NULL values in the matching column or in the equi-key columns do not produce a match. If a left-table row has NULL in the matching column, or if no qualifying right-table row exists in the same group, the right-side columns are filled with NULL (LEFT JOIN) or the row is discarded (INNER JOIN). diff --git a/docs/query-data/mysql-compatibility.md b/docs/query-data/mysql-compatibility.md index ca8f8286904de..173befe59cf6e 100644 --- a/docs/query-data/mysql-compatibility.md +++ b/docs/query-data/mysql-compatibility.md @@ -58,6 +58,8 @@ The differences from MySQL are listed below, grouped by numeric, date, string, J | Time | - Supported
- Time[(p)]
- Range: ['-838:59:59.000000', '838:59:59.000000']
- Format: hh:mm:ss[.fraction] | - Supported for computation, cannot be stored as a column in OLAP tables
- Time[(p)]
- Range: ['-838:59:59.999999', '838:59:59.999999']
- Format: hh:mm:ss[.fraction] | | Year | - Supported
- Range: 1901 to 2155, or 0000
- Format: yyyy | Not supported | +`TIMESTAMP_NS` is a Doris extension rather than a MySQL `TIMESTAMP` equivalent. It is time-zone-naive, has fixed nanosecond precision, and supports the range `1677-09-21 00:12:43.145224192` through `2262-04-11 23:47:16.854775807`. + ### String Types | Type | MySQL | Doris | diff --git a/docs/query-data/udf/java-user-defined-function.md b/docs/query-data/udf/java-user-defined-function.md index adf229cb477d0..7f40283d5bdb9 100644 --- a/docs/query-data/udf/java-user-defined-function.md +++ b/docs/query-data/udf/java-user-defined-function.md @@ -59,6 +59,7 @@ The following table lists the correspondence between Doris data types and Java U | Double | Double | | Date | LocalDate | | Datetime | LocalDateTime | +| TimestampNs | LocalDateTime | | IPV4 / IPV6 | InetAddress | | String | String | | Decimal | BigDecimal | diff --git a/docs/sql-manual/basic-element/literal/date-literal.md b/docs/sql-manual/basic-element/literal/date-literal.md index c72d22603cc9a..f7d708f8330d7 100644 --- a/docs/sql-manual/basic-element/literal/date-literal.md +++ b/docs/sql-manual/basic-element/literal/date-literal.md @@ -22,12 +22,12 @@ TIMESTAMP '2008-08-08 20:08:08' - Use a string separated by `-` in the format `'YYYY-MM-DD'` or `'YY-MM-DD'`. Doris also supports MySQL's non-standard separator formats, but their use is not recommended. - As a string without separators, use the format `'YYYYMMDD'` or `'YYMMDD'` (provided the string is meaningful as a date). -### DATETIME and TIMESTAMPTZ Literal +### DATETIME, TIMESTAMP_NS, and TIMESTAMPTZ Literal - Use a string separated by `-` in the format `'YYYY-MM-DD hh:mm:ss'` or `'YY-MM-DD hh:mm:ss'`. Doris also supports MySQL's non-standard separator formats, but their use is not recommended. The separator between date and time can be a space (` `) or `T`. **Unlike MySQL 8.4 and earlier versions, Doris does not support any other separators between time and date.** - As a string without separators, use the format `'YYYYMMDDhhmmss'` or `'YYMMDDhhmmss'` (provided the string is meaningful as a date). -DATETIME literals can include a fractional second part with a precision up to microseconds (six digits). The fractional part should always be separated from the rest of the time with a dot (`.`); other fractional second separators are not recognized. +Date-time literals can include a fractional second part. `DATETIME` and `TIMESTAMPTZ` retain up to six digits (microseconds), while `TIMESTAMP_NS` retains nine digits (nanoseconds). Extra digits are rounded to the target type's precision. The fractional part must be separated from the rest of the time with a dot (`.`); other fractional-second separators are not recognized. ### Two-Digit Years @@ -38,7 +38,7 @@ Dates containing two-digit year values are ambiguous because the century is unkn ### Time Zones -DATE, DATETIME and TIMESTAMPTZ literals can use time zone suffixes. When using time zones, the time zone must be immediately adjacent to the previous date or time part, with no spaces in between. For example: +DATE, DATETIME, TIMESTAMP_NS, and TIMESTAMPTZ literals can use time zone suffixes. When using time zones, the time zone must be immediately adjacent to the previous date or time part, with no spaces in between. For example: ```sql TIMESTAMP '2008-08-08 20:08:08+08:00' @@ -61,4 +61,4 @@ Will produce the following error: ```sql date/datetime literal [071332] is invalid -``` \ No newline at end of file +``` diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/cast-expr.md b/docs/sql-manual/basic-element/sql-data-types/conversion/cast-expr.md index a2205f1bef269..f53345dbc8276 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/cast-expr.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/cast-expr.md @@ -98,10 +98,12 @@ We categorize CAST by the target_data_type: - [Cast to DATE](./date-conversion.md) - [Cast to TIME](./time-conversion.md) - [Cast to DATETIME](./datetime-conversion.md) +- [Cast to TIMESTAMP_NS](./timestamp-ns-conversion.md) - [Cast to TIMESTAMPTZ](./timestamptz-conversion.md) - [Cast to integers (INT, etc.)](./int-conversion.md) - [Cast to floating point (FLOAT/DOUBLE)](./float-double-conversion.md) - [Cast to DECIMAL](./decimal-conversion.md) +- [Cast to CHAR/VARCHAR/STRING](./cast-to-string.md) - [Cast to JSON / From JSON to other types](./json-conversion.md) - [Cast to MAP](./map-conversion.md) - [Cast to STRUCT](./struct-conversion.md) @@ -123,4 +125,3 @@ length(CAST(123 AS varchar(65533))) ``` You can see from the execution plan above that the system automatically performs a CAST conversion, converting the integer 123 to a string type. This is an example of implicit CAST. - diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/cast-to-string.md b/docs/sql-manual/basic-element/sql-data-types/conversion/cast-to-string.md index b1a749786b2f2..3219336ef3271 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/cast-to-string.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/cast-to-string.md @@ -207,6 +207,24 @@ select cast(cast('20020304121212.123' as datetime(3)) as string); +-----------------------------------------------------------+ ``` +## TIMESTAMP_NS + +`TIMESTAMP_NS` is formatted as `yyyy-MM-dd HH:mm:ss.SSSSSSSSS`. The fractional-second part always contains exactly nine digits, including trailing zeros. The output does not contain a time zone. + +The same representation is used when converting to `CHAR`, `VARCHAR`, or `STRING`. A `NULL` input returns `NULL`. + +```sql +SELECT CAST(CAST('2024-02-29 12:34:56.123456' AS TIMESTAMP_NS) AS STRING) AS str_value; +``` + +```text ++-------------------------------+ +| str_value | ++-------------------------------+ +| 2024-02-29 12:34:56.123456000 | ++-------------------------------+ +``` + ## Time Time type is output in "hour:minute:second" format. The hour can be at most 3 digits, at least 2 digits, and can be negative; minutes and seconds are always 2 digits. If the type's `Scale` is not 0, then outputs the decimal point and `Scale` digits of fractional seconds. diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/date-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/date-conversion.md index 45185a50b6dd9..d799706c9466d 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/date-conversion.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/date-conversion.md @@ -490,3 +490,18 @@ Assume the current date is 2025-04-29, then: | `500:00:00` | `2025-05-19` | | `23:59:59` | `2025-04-29` | | `-128:00:00` | `2025-04-23` | + +### TIMESTAMP_NS + +#### Rule Description + +When converting from `TIMESTAMP_NS`, Doris returns the date part and discards the time and fractional-second parts without rounding. Every valid `TIMESTAMP_NS` value is within the `DATE` range, so the conversion always succeeds in both strict and non-strict modes. A `NULL` input returns `NULL`. + +#### Examples + +| Input TIMESTAMP_NS | Cast as DATE Result | +| --- | --- | +| `1677-09-21 00:12:43.145224192` | `1677-09-21` | +| `1969-12-31 23:59:59.999999999` | `1969-12-31` | +| `2024-02-29 12:34:56.123456789` | `2024-02-29` | +| `2262-04-11 23:47:16.854775807` | `2262-04-11` | diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion.md index b1971af8eb988..6ad98fbda4963 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion.md @@ -618,3 +618,16 @@ If an overflow occurs, NULL is returned. | `2020-12-12 00:00:00.123456+08:00` | Timestamptz(6) | Datetime(3) | `2020-12-12 00:00:00.123` | Decrease precision, no carr | | `2020-12-12 00:00:00.99666+08:00` | Timestamptz(6) | Datetime(2) | `2020-12-12 00:00:01.00` | Decrease precision, carry to second | | `9999-12-31 23:59:59.999999+08:00` | Timestamptz(6) | Datetime(5) | NULL | Carry overflow, produces an invalid date of year 10000 | + +### TIMESTAMP_NS + +`TIMESTAMP_NS` is time-zone-naive like `DATETIME`, so the conversion preserves the civil date and time without applying a time zone adjustment. Because `TIMESTAMP_NS` always has nine fractional digits and `DATETIME` supports at most six, the fractional part is rounded to the target `DATETIME` precision. A carry can propagate to the next second. + +Every valid `TIMESTAMP_NS` value is within the `DATETIME` date range, so conversion always succeeds in both strict and non-strict modes. A `NULL` input returns `NULL`. + +| Input TIMESTAMP_NS | Target Type | Result DATETIME | Comment | +| --- | --- | --- | --- | +| `2024-02-29 12:34:56.123456499` | Datetime(6) | `2024-02-29 12:34:56.123456` | Discarded digits round down | +| `2024-02-29 12:34:56.123456500` | Datetime(6) | `2024-02-29 12:34:56.123457` | Discarded digits round up | +| `1969-12-31 23:59:59.999999500` | Datetime(6) | `1970-01-01 00:00:00.000000` | Carry to the next second and date | +| `2024-02-29 12:34:56.123456789` | Datetime(3) | `2024-02-29 12:34:56.123` | Round to millisecond precision | diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/decimal-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/decimal-conversion.md index d9e1a3e89de32..618d5bda2935b 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/decimal-conversion.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/decimal-conversion.md @@ -266,6 +266,10 @@ Not supported. Not supported. +## From TIMESTAMP_NS + +Not supported. + ## From time Not supported. diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/float-double-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/float-double-conversion.md index ea2ba7bca4735..4bdc96b9230b5 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/float-double-conversion.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/float-double-conversion.md @@ -348,6 +348,47 @@ If the source type is non-nullable, returns non-nullable type. | 838:59:58 | 3020398000000 | | | 838:59:58.123456 | 3020398123456 | | +## From TIMESTAMP_NS to float + +### Strict mode + +Return error. + +### Non-strict mode + +Doris discards the nine-digit fractional-second part without rounding, concatenates the year, month, day, hour, minute, and second as a `YYYYMMDDHHMMSS` integer, and then uses `static_cast` to convert the integer to `FLOAT`. Because `FLOAT` has fewer significant digits than the 14-digit integer, this conversion usually loses precision. + +If the source type is nullable, the return type is nullable. + +If the source type is non-nullable, the return type is non-nullable. + +#### Examples + +| TIMESTAMP_NS | float | Comment | +| --- | --- | --- | +| `2024-02-29 12:34:56.123456789` | `2.02402284E13` | The fractional part is discarded and the 14-digit integer loses precision | + +## From TIMESTAMP_NS to double + +### Strict mode + +Return error. + +### Non-strict mode + +Doris discards the nine-digit fractional-second part without rounding, concatenates the year, month, day, hour, minute, and second as a `YYYYMMDDHHMMSS` integer, and then uses `static_cast` to convert the integer to `DOUBLE`. `DOUBLE` can exactly represent every 14-digit result in the `TIMESTAMP_NS` range. + +If the source type is nullable, the return type is nullable. + +If the source type is non-nullable, the return type is non-nullable. + +#### Examples + +| TIMESTAMP_NS | double | Comment | +| --- | --- | --- | +| `2024-02-29 12:34:56.123456789` | `20240229123456` | No precision loss | +| `2262-04-11 23:47:16.854775807` | `22620411234716` | The fractional part is discarded | + ## From other types -Not supported. \ No newline at end of file +Not supported. diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/int-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/int-conversion.md index ab136e0b2433f..c5c51f896201f 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/int-conversion.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/int-conversion.md @@ -199,6 +199,27 @@ Since version 4.0, does not support casting datetime to tinyint, smallint and in | 2025-03-14 17:00:01.123456 | 20250314170001 | | 9999-12-31 23:59:59.999999 | 99991231235959 | +## From TIMESTAMP_NS + +If the source type is nullable, returns nullable type. + +If the source type is non-nullable, returns non-nullable type. + +### Rule description + +* Does not support casting to tinyint, smallint, or int, as overflow will definitely occur. + +* Supports casting to bigint and largeint. Discards the nanosecond part of TIMESTAMP_NS, then concatenates year, month, day, hour, minute, and second in order to form an integer, with month, day, hour, minute, and second treated as two digits, padding with a leading 0 if less than 10. + +### Examples + +| Input TIMESTAMP_NS | Target Type | Result | +| --- | --- | --- | +| `1677-09-21 00:12:43.145224192` | `BIGINT` | `16770921001243` | +| `1969-12-31 23:59:59.999999999` | `BIGINT` | `19691231235959` | +| `2024-02-29 12:34:56.123456789` | `LARGEINT` | `20240229123456` | +| `2262-04-11 23:47:16.854775807` | `LARGEINT` | `22620411234716` | + ## From float/double Does not support rounding. diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/overview.md b/docs/sql-manual/basic-element/sql-data-types/conversion/overview.md index 1d896dbd51b04..4694b26913992 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/overview.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/overview.md @@ -35,61 +35,65 @@ The specific type conversion rules and Nullable properties, please check the typ ### Strict Mode -| **From**\\**To** | bool | tinyint | smallint | int | bigint | largeint | float | double | decimal | date | datetime | time | IPv4 | IPv6 | char | varchar | string | bitmap | hll | json | array | map | struct | variant | -| ---------------- | ---- | ------- | -------- | --- | ------ | -------- | ----- | ------ | ------- | ---- | -------- | ---- | ---- | ---- | ---- | ------- | ------ | ------ | --- | ---- | ----- | --- | ------ | ------- | -| bool | P | P | P | P | P | P | P | P | O | x | x | x | x | x | | | | x | x | P | x | x | x | | -| tinyint | P | P | P | P | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| smallint | P | A | P | P | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| int | P | A | A | P | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| bigint | P | A | A | A | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| largeint | P | A | A | A | A | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| float | P | A | A | A | A | A | P | P | A | A | A | A | x | x | | | | x | x | P | x | x | x | | -| double | P | A | A | A | A | A | P | P | A | A | A | A | x | x | | | | x | x | P | x | x | x | | -| decimal | P | O | O | O | O | O | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| date | x | x | x | P | P | P | x | x | x | P | P | x | x | x | | | | x | x | x | x | x | x | | -| datetime | x | x | x | x | P | P | x | x | x | P | A | P | x | x | | | | x | x | x | x | x | x | | -| time | x | A | A | A | P | P | x | x | x | P | P | A | x | x | | | | x | x | x | x | x | x | | -| IPv4 | x | x | x | x | x | x | x | x | x | x | x | x | P | P | | | | x | x | x | x | x | x | | -| IPv6 | x | x | x | x | x | x | x | x | x | x | x | x | x | P | | | | x | x | x | x | x | x | | -| char | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | -| varchar | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | -| string | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | -| bitmap | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | x | | -| hll | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | | -| json | A | A | A | A | A | A | A | A | A | x | x | x | x | x | A | A | A | x | x | P | A | x | A | | -| array | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | P | x | x | | -| map | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | x | x | P | x | | -| struct | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | x | x | P | | -| variant | | | | | | | | | | | | | | | | | | | | | | | | | +| **From**\\**To** | bool | tinyint | smallint | int | bigint | largeint | float | double | decimal | date | datetime | timestamp_ns | time | IPv4 | IPv6 | char | varchar | string | bitmap | hll | json | array | map | struct | variant | +| ---------------- | ---- | ------- | -------- | --- | ------ | -------- | ----- | ------ | ------- | ---- | -------- | ------------ | ---- | ---- | ---- | ---- | ------- | ------ | ------ | --- | ---- | ----- | --- | ------ | ------- | +| bool | P | P | P | P | P | P | P | P | O | x | x | x | x | x | x | | | | x | x | P | x | x | x | | +| tinyint | P | P | P | P | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| smallint | P | A | P | P | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| int | P | A | A | P | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| bigint | P | A | A | A | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| largeint | P | A | A | A | A | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| float | P | A | A | A | A | A | P | P | A | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| double | P | A | A | A | A | A | P | P | A | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| decimal | P | O | O | O | O | O | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| date | x | x | x | P | P | P | x | x | x | P | P | A | x | x | x | | | | x | x | x | x | x | x | | +| datetime | x | x | x | x | P | P | x | x | x | P | A | A | P | x | x | | | | x | x | x | x | x | x | | +| timestamp_ns | x | x | x | x | P | P | x | x | x | P | P | P | P | x | x | P | P | P | x | x | x | x | x | x | P | +| time | x | A | A | A | P | P | x | x | x | P | P | P | A | x | x | | | | x | x | x | x | x | x | | +| IPv4 | x | x | x | x | x | x | x | x | x | x | x | x | x | P | P | | | | x | x | x | x | x | x | | +| IPv6 | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | | | | x | x | x | x | x | x | | +| char | A | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | +| varchar | A | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | +| string | A | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | +| bitmap | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | x | | +| hll | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | | +| json | A | A | A | A | A | A | A | A | A | x | x | x | x | x | x | A | A | A | x | x | P | A | x | A | | +| array | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | P | x | x | | +| map | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | x | x | P | x | | +| struct | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | x | x | P | | +| variant | | | | | | | | | | | | A | | | | | | | | | | | | | | ### Non-strict Mode -| **From**\\**To** | bool | tinyint | smallint | int | bigint | largeint | float | double | decimal | date | datetime | time | IPv4 | IPv6 | char | varchar | string | bitmap | hll | json | array | map | struct | variant | -| ---------------- | ---- | ------- | -------- | --- | ------ | -------- | ----- | ------ | ------- | ---- | -------- | ---- | ---- | ---- | ---- | ------- | ------ | ------ | --- | ---- | ----- | --- | ------ | ------- | -| bool | P | P | P | P | P | P | P | P | O | x | x | x | x | x | | | | x | x | P | x | x | x | | -| tinyint | P | P | P | P | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| smallint | P | A | P | P | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| int | P | A | A | P | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| bigint | P | A | A | A | P | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| largeint | P | A | A | A | A | P | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| float | P | A | A | A | A | A | P | P | A | A | A | A | x | x | | | | x | x | P | x | x | x | | -| double | P | A | A | A | A | A | P | P | A | A | A | A | x | x | | | | x | x | P | x | x | x | | -| decimal | P | O | O | O | O | O | P | P | O | A | A | A | x | x | | | | x | x | P | x | x | x | | -| date | x | x | x | P | P | P | P | P | x | P | P | x | x | x | | | | x | x | x | x | x | x | | -| datetime | x | x | x | x | P | P | P | P | x | P | A | P | x | x | | | | x | x | x | x | x | x | | -| time | x | A | A | A | P | P | P | P | x | P | P | A | x | x | | | | x | x | x | x | x | x | | -| IPv4 | x | x | x | x | x | x | x | x | x | x | x | x | P | P | | | | x | x | x | x | x | x | | -| IPv6 | x | x | x | x | x | x | x | x | x | x | x | x | x | P | | | | x | x | x | x | x | x | | -| char | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | -| varchar | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | -| string | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | -| bitmap | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | x | | -| hll | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | | -| json | A | A | A | A | A | A | A | A | A | x | x | x | x | x | A | A | A | x | x | P | A | x | A | | -| array | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | P | x | x | | -| map | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | x | x | P | x | | -| struct | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | x | x | P | | -| variant | | | | | | | | | | | | | | | | | | | | | | | | | +| **From**\\**To** | bool | tinyint | smallint | int | bigint | largeint | float | double | decimal | date | datetime | timestamp_ns | time | IPv4 | IPv6 | char | varchar | string | bitmap | hll | json | array | map | struct | variant | +| ---------------- | ---- | ------- | -------- | --- | ------ | -------- | ----- | ------ | ------- | ---- | -------- | ------------ | ---- | ---- | ---- | ---- | ------- | ------ | ------ | --- | ---- | ----- | --- | ------ | ------- | +| bool | P | P | P | P | P | P | P | P | O | x | x | x | x | x | x | | | | x | x | P | x | x | x | | +| tinyint | P | P | P | P | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| smallint | P | A | P | P | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| int | P | A | A | P | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| bigint | P | A | A | A | P | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| largeint | P | A | A | A | A | P | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| float | P | A | A | A | A | A | P | P | A | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| double | P | A | A | A | A | A | P | P | A | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| decimal | P | O | O | O | O | O | P | P | O | A | A | A | A | x | x | | | | x | x | P | x | x | x | | +| date | x | x | x | P | P | P | P | P | x | P | P | A | x | x | x | | | | x | x | x | x | x | x | | +| datetime | x | x | x | x | P | P | P | P | x | P | A | A | P | x | x | | | | x | x | x | x | x | x | | +| timestamp_ns | x | x | x | x | P | P | P | P | x | P | P | P | P | x | x | P | P | P | x | x | x | x | x | x | P | +| time | x | A | A | A | P | P | P | P | x | P | P | P | A | x | x | | | | x | x | x | x | x | x | | +| IPv4 | x | x | x | x | x | x | x | x | x | x | x | x | x | P | P | | | | x | x | x | x | x | x | | +| IPv6 | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | | | | x | x | x | x | x | x | | +| char | A | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | +| varchar | A | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | +| string | A | A | A | A | A | A | A | A | A | A | A | A | A | A | A | | | | x | x | A | A | A | A | | +| bitmap | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | x | | +| hll | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | P | x | x | x | x | | +| json | A | A | A | A | A | A | A | A | A | x | x | x | x | x | x | A | A | A | x | x | P | A | x | A | | +| array | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | P | x | x | | +| map | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | x | x | P | x | | +| struct | x | x | x | x | x | x | x | x | x | x | x | x | x | x | x | | | | x | x | P | x | x | P | | +| variant | | | | | | | | | | | | A | | | | | | | | | | | | | | + +For detailed `TIMESTAMP_NS` conversion rules, see [Cast to TIMESTAMP_NS](./timestamp-ns-conversion.md). `TIMESTAMPTZ` is not included in the matrices above; conversion between `TIMESTAMP_NS` and `TIMESTAMPTZ` is supported in both strict and non-strict modes. ## Implicit Conversion diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion.md index 188d2fea84c73..672e166f0141c 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion.md @@ -320,3 +320,18 @@ If an overflow occurs, NULL is returned. | `00:00:00.123456` | TIME(6) | TIME(3) | `00:00:00.123` | Reduced precision, no carry | | `120:00:00.99666` | TIME(6) | TIME(2) | `120:00:01.00` | Reduced precision, carries to seconds | | `838:59:59.999999` | TIME(6) | TIME(5) | NULL | Carry overflow, produces invalid TIME | + +### From TIMESTAMP_NS + +The result is the time-of-day part of the input. Because `TIME(p)` supports precision `p` from 0 to 6, Doris rounds the nine-digit fractional second to the target precision. A carry can propagate to the next second; rounding `23:59:59.999999999` can therefore produce `24:00:00`. + +Every valid `TIMESTAMP_NS` time-of-day value is within the `TIME` range, so the conversion always succeeds in both strict and non-strict modes. A `NULL` input returns `NULL`. + +#### Examples + +| Input TIMESTAMP_NS | Target Type | Cast as TIME Result | Comment | +| --- | --- | --- | --- | +| `2024-02-29 12:34:56.123456789` | `TIME(0)` | `12:34:56` | Rounds to whole seconds | +| `2024-02-29 12:34:56.123456789` | `TIME(3)` | `12:34:56.123` | Rounds to milliseconds | +| `2024-02-29 12:34:56.123456789` | `TIME(6)` | `12:34:56.123457` | Rounds to microseconds | +| `1969-12-31 23:59:59.999999999` | `TIME(6)` | `24:00:00.000000` | Carry to the next second | diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/timestamp-ns-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/timestamp-ns-conversion.md new file mode 100644 index 0000000000000..1d68fca1081d8 --- /dev/null +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/timestamp-ns-conversion.md @@ -0,0 +1,273 @@ +--- +{ + "title": "Cast to TIMESTAMP_NS Type", + "language": "en", + "description": "Rules for converting character, numeric, and temporal values to the fixed nanosecond-precision TIMESTAMP_NS type." +} +--- + +## Description + +`TIMESTAMP_NS` has fixed nanosecond precision and the exact range `[1677-09-21 00:12:43.145224192, 2262-04-11 23:47:16.854775807]`. It does not accept a precision parameter. + +String and numeric values generally use the same field mapping as [`DATETIME`](./datetime-conversion.md). In both strict and non-strict cast modes, `TIMESTAMP_NS` supports exactly the same string formats as `DATETIME` in the corresponding mode. The only difference in string format capability is that `TIMESTAMP_NS` supports up to nine fractional-second digits of precision, whereas `DATETIME` supports up to six. + +## Syntax + +```sql +CAST( AS TIMESTAMP_NS) +TRY_CAST( AS TIMESTAMP_NS) +``` + +## Supported Source Types + +| Source type | Conversion behavior | +| --- | --- | +| `CHAR`, `VARCHAR`, `STRING` | Parses a date-time string using the corresponding strict or non-strict `DATETIME` string grammar, with up to nine fractional-second digits of precision. | +| Integer types | Interprets the value as a compact date or date-time. | +| `FLOAT` | Uses the value actually represented by the single-precision input; loss of significant digits can make a large compact date-time invalid. | +| `DOUBLE` | Uses the value actually represented by the double-precision input; the fractional part represents fractional seconds. | +| `DECIMAL` types | Interprets the integer part as a compact date or date-time and the decimal part as fractional seconds. | +| `DATE` | Adds `00:00:00.000000000`. | +| `DATETIME(p)` | Preserves the civil date and time and pads the fraction with zeros to nine digits. | +| `TIME(p)` | Adds the input duration to midnight of the current date. | +| `TIMESTAMPTZ(p)` | Converts the instant to the current session time zone and then removes the time zone. | +| `TIMESTAMP_NS` | Returns the value unchanged. | +| `VARIANT` | Extracts a compatible scalar value and applies the corresponding string, numeric, or temporal conversion rule. | +| `NULL` | Returns `NULL`. | + +Conversions from unsupported types, including `BOOLEAN`, `JSON`, IP, binary, and complex types, fail during analysis. This is a type error rather than a value-conversion error, so neither non-strict `CAST` nor `TRY_CAST` changes it to `NULL`. + +## From String + +### Strict Mode + +When `enable_strict_cast = true`, the supported formats and parsing rules are exactly the same as those in the [strict-mode `DATETIME` string conversion](./datetime-conversion.md#from-string). This includes the rules for date and time fields, two-digit years, omitted time fields, consecutive digits, whitespace, and time zone suffixes. + +### Non-strict Mode + +When `enable_strict_cast = false`, the supported formats and parsing rules are exactly the same as those in the [non-strict-mode `DATETIME` string conversion](./datetime-conversion.md#from-string). All strict-mode formats remain valid, and the additional separators, delimiters, and leading or trailing whitespace accepted by non-strict `DATETIME` are also accepted by `TIMESTAMP_NS`. + +The difference between the two modes when casting to `TIMESTAMP_NS` is the same as for `DATETIME`: a format or domain error raises an error in strict mode and returns `NULL` in non-strict mode. + +### Fractional Seconds + +The only difference from the corresponding `DATETIME` string formats is the supported fractional-second precision: + +- The target scale is always 9. A fraction with fewer than nine digits is padded on the right with zeros. +- A fraction with more than nine digits is rounded half up. The tenth digit determines whether the ninth digit is incremented; later digits do not affect the result. +- A rounding carry propagates normally to the second, date, or year. +- Doris validates the `TIMESTAMP_NS` range after fractional rounding and time zone conversion. + +### Time Zone Handling + +`TIMESTAMP_NS` does not store a time zone: + +- Without a time zone suffix, the parsed civil date and time is stored unchanged. +- With a numeric offset, UTC designator, or IANA time zone name, Doris converts the input instant to the current session time zone and stores the resulting civil date and time without a time zone. +- Changing the session time zone after the value has been stored does not change the stored value. + +For the accepted time zone suffixes and names, see the [`DATETIME` string conversion rules](./datetime-conversion.md#from-string) and [Time Zone](../../../../admin-manual/cluster-management/time-zone). + +Assume `time_zone = '+08:00'` for the following examples: + +| String | Mode | Result | Explanation | +| --- | --- | --- | --- | +| `2024-02-29 12:34:56.123456` | Both | `2024-02-29 12:34:56.123456000` | Pads the fraction to nine digits. | +| `2024-02-29 12:34:56.1234567894` | Both | `2024-02-29 12:34:56.123456789` | The tenth digit is less than 5, so the value rounds down. | +| `2024-02-29 12:34:56.1234567895` | Both | `2024-02-29 12:34:56.123456790` | The tenth digit is 5, so the value rounds up. | +| `2024-02-29 12:34:56.9999999995` | Both | `2024-02-29 12:34:57.000000000` | The rounding carry reaches the next second. | +| `2024-02-29T04:34:56.123456789Z` | Both | `2024-02-29 12:34:56.123456789` | Converts UTC to the session time zone and removes the time zone. | +| ` 2023-7-4T9-5-3.1Z ` | Non-strict only | `2023-07-04 17:05:03.100000000` | Uses non-strict separators and leading or trailing whitespace. | +| `2024-02-30 12:34:56` | Both | Invalid | February 30 is not a Gregorian calendar date. | +| `2024-01-01 00:00:00.123.456` | Both | Invalid | The fractional-second syntax is invalid. | + +### Boundary Rounding + +Rounding occurs before the final range check. Therefore, an input immediately outside a boundary can become valid after rounding, while an input at the upper boundary can become invalid after rounding up. + +| String | Result | +| --- | --- | +| `1677-09-21 00:12:43.1452241914` | Invalid: below the lower limit after rounding | +| `1677-09-21 00:12:43.1452241915` | `1677-09-21 00:12:43.145224192` | +| `2262-04-11 23:47:16.8547758074` | `2262-04-11 23:47:16.854775807` | +| `2262-04-11 23:47:16.8547758075` | Invalid: above the upper limit after rounding | + +## From Numeric + +All integer, floating-point, and decimal types can be converted to `TIMESTAMP_NS`. `BOOLEAN` is not supported. + +The integer-part field mapping, two-digit year rule, and valid compact representations are the same as [numeric-to-`DATETIME` conversion](./datetime-conversion.md#from-numeric). In particular, valid representations contain 3, 4, 5, 6, 8, or 14 integer digits. The decimal part represents fractional seconds. + +The compact date-time and the fractional part must produce a value within the `TIMESTAMP_NS` range. Fractional seconds are padded or rounded to exactly nine digits using the same half-up rule as string input. + +### From Integer Types + +Integer types have no fractional part. Doris applies the compact numeric field mapping and appends `.000000000` to the result. + +| Integer value | Result | Explanation | +| --- | --- | --- | +| `123` | `2000-01-23 00:00:00.000000000` | Three-digit compact date. | +| `20240229` | `2024-02-29 00:00:00.000000000` | Eight-digit compact date. | +| `20240229123456` | `2024-02-29 12:34:56.000000000` | Fourteen-digit compact date-time. | +| `16770921001243` | Invalid | The resulting time is below the lower limit. | +| `22620412000000` | Invalid | The resulting time is above the upper limit. | + +### From FLOAT + +`FLOAT` uses the decimal value represented by the single-precision input before the cast. Its limited number of significant digits is generally insufficient for a 14-digit compact date-time, so a large input can lose digits and become an invalid date-time. Use `DOUBLE` or `DECIMAL` for large compact values. + +| FLOAT input expression | Strict-mode result | Non-strict-mode result | Explanation | +| --- | --- | --- | --- | +| `CAST(123 AS FLOAT)` | `2000-01-23 00:00:00.000000000` | `2000-01-23 00:00:00.000000000` | The represented value is exact. | +| `CAST(20240229123456.125 AS FLOAT)` | Error | `NULL` | Significant-digit loss makes the represented compact date-time invalid. | + +### From DOUBLE + +`DOUBLE` uses the decimal value represented by the double-precision input before the cast. It can exactly represent the 14-digit integer part of every compact `TIMESTAMP_NS` value, but a decimal fraction that is not exactly representable in binary can still be rounded before conversion. Use `DECIMAL` when every input fractional digit must be preserved. + +| DOUBLE input expression | Result | Explanation | +| --- | --- | --- | +| `CAST(20240229123456.125 AS DOUBLE)` | `2024-02-29 12:34:56.125000000` | The integer and fractional parts are exactly representable. | + +### From DECIMAL + +`DECIMAL` preserves its literal decimal representation. Digits beyond nanosecond precision are rounded half-up to nine fractional digits. + +| DECIMAL input expression | Result | Explanation | +| --- | --- | --- | +| `CAST(20240229123456.1234567895 AS DECIMAL(24, 10))` | `2024-02-29 12:34:56.123456790` | The fraction is rounded to nanoseconds. | + +### Error Handling + +Strict and non-strict modes use the same numeric mapping. If the represented numeric value cannot produce a valid in-range `TIMESTAMP_NS`, strict mode reports an error and non-strict mode returns `NULL`. A `NULL` input returns `NULL` in both modes. + +## From Datelike Types + +### From DATE + +Doris appends `00:00:00.000000000` to the input date and then checks the `TIMESTAMP_NS` range. Because midnight on the lower boundary date is outside the range, `1677-09-21` cannot be converted; the earliest convertible `DATE` is `1677-09-22`. The latest convertible `DATE` is `2262-04-11`. + +| Input `DATE` | Result | +| --- | --- | +| `1677-09-21` | Invalid | +| `1677-09-22` | `1677-09-22 00:00:00.000000000` | +| `2262-04-11` | `2262-04-11 00:00:00.000000000` | +| `2262-04-12` | Invalid | + +### From DATETIME + +`DATETIME` and `TIMESTAMP_NS` are both time-zone-naive, so Doris preserves the civil date and time without a time zone adjustment. A `DATETIME(p)` fraction is padded on the right with zeros to nine digits; no precision is invented beyond the source value. + +The padded result must be within the `TIMESTAMP_NS` range. Because `DATETIME` supports at most microsecond precision, the earliest convertible value on the lower boundary is `1677-09-21 00:12:43.145225`, and the latest convertible value on the upper boundary is `2262-04-11 23:47:16.854775`. + +| Input `DATETIME(6)` | Result | +| --- | --- | +| `1677-09-21 00:12:43.145224` | Invalid | +| `1677-09-21 00:12:43.145225` | `1677-09-21 00:12:43.145225000` | +| `2024-02-29 12:34:56.123456` | `2024-02-29 12:34:56.123456000` | +| `2262-04-11 23:47:16.854775` | `2262-04-11 23:47:16.854775000` | +| `2262-04-11 23:47:16.854776` | Invalid | + +### From TIME + +Doris starts with midnight of the current date in the session time zone and adds the signed `TIME` duration. The duration can cross a date boundary. The fractional part has at most microsecond precision and is padded with zeros to nine digits. Doris then checks that the final date and time is within the `TIMESTAMP_NS` range. + +For example, if the current date is `2025-04-29`: + +| Input `TIME(6)` | Result | +| --- | --- | +| `12:34:56.123456` | `2025-04-29 12:34:56.123456000` | +| `500:00:00.000000` | `2025-05-19 20:00:00.000000000` | +| `-128:00:00.000000` | `2025-04-23 16:00:00.000000000` | + +Because this conversion depends on the current date, use an explicit `DATE` or `DATETIME` instead when a reproducible calendar date is required. + +### From TIMESTAMPTZ + +Doris converts the represented instant to the current session time zone, removes the time zone, and pads the source fraction with zeros to nine digits. The final local date and time must be within the `TIMESTAMP_NS` range. + +Changing `time_zone` can therefore change the result of the cast and can move a boundary value into or out of the supported range. + +```sql +SET time_zone = '+08:00'; +SELECT CAST(CAST('2024-02-29 04:34:56.123456+00:00' AS TIMESTAMPTZ(6)) AS TIMESTAMP_NS) AS ts; +``` + +```text ++-------------------------------+ +| ts | ++-------------------------------+ +| 2024-02-29 12:34:56.123456000 | ++-------------------------------+ +``` + +### From TIMESTAMP_NS and VARIANT + +Casting a `TIMESTAMP_NS` value to the same type preserves it exactly. A compatible string, numeric, date, or timestamp value stored in `VARIANT` follows the corresponding rule above. Zoned timestamp values are converted to the current session time zone; time-zone-naive timestamp values preserve their civil fields. Incompatible `VARIANT` contents return `NULL` or report an error according to the cast mode. + +## Related Conversions + +Converting `TIMESTAMP_NS` to [`DATETIME(p)`](./datetime-conversion.md) or [`TIMESTAMPTZ(p)`](./timestamptz-conversion.md) rounds the fraction to the target precision. For example, converting `2024-02-29 12:34:56.123456789` to precision 6 produces `2024-02-29 12:34:56.123457`. + +When `TIMESTAMP_NS` and `DATETIME` values are combined in comparisons, joins, `CASE`, `COALESCE`, or set operations, Doris uses `TIMESTAMP_NS` as the common type when it can preserve the values exactly. + +## Error Handling + +| Situation | `enable_strict_cast = true` | `enable_strict_cast = false` | `TRY_CAST` | +| --- | --- | --- | --- | +| Invalid format or calendar value | Error | `NULL` | `NULL` | +| Value outside the `TIMESTAMP_NS` range | Error | `NULL` | `NULL` | +| Source value is `NULL` | `NULL` | `NULL` | `NULL` | +| Unsupported source-target type pair | Analysis error | Analysis error | Analysis error | + +For string input, `enable_strict_cast` selects the corresponding strict or non-strict `DATETIME` parsing rules and controls the handling of conversion failures. For numeric input, it changes only error handling; the numeric mapping is the same in both modes. + +## Examples + +Convert strings at nanosecond precision and observe rounding: + +```sql +SELECT + CAST('2024-02-29 12:34:56.123456' AS TIMESTAMP_NS) AS padded, + CAST('2024-02-29 12:34:56.1234567895' AS TIMESTAMP_NS) AS rounded; +``` + +```text ++-------------------------------+-------------------------------+ +| padded | rounded | ++-------------------------------+-------------------------------+ +| 2024-02-29 12:34:56.123456000 | 2024-02-29 12:34:56.123456790 | ++-------------------------------+-------------------------------+ +``` + +Convert a numeric date-time representation: + +```sql +SELECT CAST(CAST(20240229123456.1234567895 AS DECIMAL(24, 10)) AS TIMESTAMP_NS) AS ts; +``` + +```text ++-------------------------------+ +| ts | ++-------------------------------+ +| 2024-02-29 12:34:56.123456790 | ++-------------------------------+ +``` + +In non-strict mode, invalid and out-of-range values return `NULL`: + +```sql +SET enable_strict_cast = false; +SELECT + CAST('2024-02-30 00:00:00' AS TIMESTAMP_NS) AS invalid_date, + CAST('2262-04-11 23:47:16.8547758075' AS TIMESTAMP_NS) AS overflow; +``` + +```text ++--------------+----------+ +| invalid_date | overflow | ++--------------+----------+ +| NULL | NULL | ++--------------+----------+ +``` diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/timestamptz-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/timestamptz-conversion.md index 261b820d8127d..e4eabd39814c1 100644 --- a/docs/sql-manual/basic-element/sql-data-types/conversion/timestamptz-conversion.md +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/timestamptz-conversion.md @@ -130,3 +130,19 @@ If overflow occurs, the return value is NULL. | `2020-12-12 00:00:00.123456` | Datetime(6) | Timestamptz(3) | `2020-12-12 00:00:00.123+08:00` | Reduce precision, no carry | | `2020-12-12 00:00:00.99666` | Datetime(6) | Timestamptz(2) | `2020-12-12 00:00:01.00+08:00` | Reduce precision, carry to seconds | | `9999-12-31 23:59:59.999999` | Datetime(6) | Timestamptz(5) | NULL | Carry overflow, produces invalid date of year 10000 | + +### TIMESTAMP_NS + +When converting `TIMESTAMP_NS` to `TIMESTAMPTZ(p)`, Doris interprets the time-zone-naive `TIMESTAMP_NS` value in the current session time zone, converts it to the corresponding instant, and rounds the nanosecond fraction to the target precision `p` (`0` to `6`). + +Every valid `TIMESTAMP_NS` value is within the `TIMESTAMPTZ` date range, so conversion always succeeds in both strict and non-strict modes. A `NULL` input returns `NULL`. + +Assume `time_zone = '+08:00'`: + +| Input TIMESTAMP_NS | Target Type | Result TIMESTAMPTZ | Comment | +| --- | --- | --- | --- | +| `2024-02-29 12:34:56.123456499` | Timestamptz(6) | `2024-02-29 12:34:56.123456+08:00` | Round down to microseconds | +| `2024-02-29 12:34:56.123456500` | Timestamptz(6) | `2024-02-29 12:34:56.123457+08:00` | Round up to microseconds | +| `1969-12-31 23:59:59.999999500` | Timestamptz(6) | `1970-01-01 00:00:00.000000+08:00` | Carry to the next second | + +For conversion in the opposite direction, see [Cast to TIMESTAMP_NS](./timestamp-ns-conversion.md). diff --git a/docs/sql-manual/basic-element/sql-data-types/data-type-overview.md b/docs/sql-manual/basic-element/sql-data-types/data-type-overview.md index d2cbb092323d5..a1dfba49ed26a 100644 --- a/docs/sql-manual/basic-element/sql-data-types/data-type-overview.md +++ b/docs/sql-manual/basic-element/sql-data-types/data-type-overview.md @@ -47,11 +47,11 @@ The precise fixed-point type [DECIMAL](../sql-data-types/numeric/DECIMAL.md), us ## Date Types -Date types include DATE, TIME, DATETIME and TIMESTAMPTZ. DATE type only stores the date accurate to the day, DATETIME type stores the date and time, which can be accurate to microseconds. TIME type only stores the time, and **does not support the construction of the table storage for the time being, can only be used in the query process**. TIMESTAMPTZ is a time zone-aware date-time type that stores values in UTC and automatically converts them based on the session time zone during queries. +Date types include DATE, TIME, DATETIME, TIMESTAMP_NS and TIMESTAMPTZ. DATE stores a date accurate to the day. DATETIME stores a time-zone-naive date and time with up to microsecond precision. TIMESTAMP_NS stores a time-zone-naive date and time with fixed nanosecond precision and a range from 1677 to 2262. TIME stores only the time and **does not currently support table storage; it can only be used during query processing**. TIMESTAMPTZ is a time zone-aware date-time type that stores values in UTC and automatically converts them based on the session time zone during queries. Do calculation for datetime types or converting them to numeric types, please use functions like [TIME_TO_SEC](../../sql-functions/scalar-functions/date-time-functions/time-to-sec), [DATE_DIFF](../../sql-functions/scalar-functions/date-time-functions/datediff), [UNIX_TIMESTAMP](../../sql-functions/scalar-functions/date-time-functions/unix-timestamp) . The result of directly converting them as numeric types as not guaranteed. -For more information refer to [DATE](../sql-data-types/date-time/DATE), [TIME](../sql-data-types/date-time/TIME), [DATETIME](../sql-data-types/date-time/DATETIME) and [TIMESTAMPTZ](../sql-data-types/date-time/TIMESTAMPTZ) documents. +For more information, see [DATE](../sql-data-types/date-time/DATE), [TIME](../sql-data-types/date-time/TIME), [DATETIME](../sql-data-types/date-time/DATETIME), [TIMESTAMP_NS](../sql-data-types/date-time/TIMESTAMP-NS), and [TIMESTAMPTZ](../sql-data-types/date-time/TIMESTAMPTZ). @@ -101,4 +101,3 @@ IP data types store IP addresses in a binary format, which is faster and more sp - **[IPv4](../sql-data-types/ip/IPV4.md)**: It stores IPv4 addresses as a 4-byte binary value. It is used in conjunction with the `ipv4_*` family of functions. - **[IPv6](../sql-data-types/ip/IPV6.md)**: It stores IPv6 addresses as a 16-byte binary value. It is used in conjunction with the `ipv6_*` family of functions. - diff --git a/docs/sql-manual/basic-element/sql-data-types/date-time/DATETIME.md b/docs/sql-manual/basic-element/sql-data-types/date-time/DATETIME.md index 1853c4752f648..5f9faa5354957 100644 --- a/docs/sql-manual/basic-element/sql-data-types/date-time/DATETIME.md +++ b/docs/sql-manual/basic-element/sql-data-types/date-time/DATETIME.md @@ -22,6 +22,8 @@ Date and time types do not support direct use of mathematical operators for arit DATETIME type does not store time zone, that is, changes in the session variable `time_zone` do not affect the stored values of DATETIME type. +Use [`TIMESTAMP_NS`](./TIMESTAMP-NS.md) when nanosecond precision is required. `TIMESTAMP_NS` is also time-zone-naive, but its supported range is limited to 1677-09-21 through 2262-04-11. + ## Examples ```sql diff --git a/docs/sql-manual/basic-element/sql-data-types/date-time/TIMESTAMP-NS.md b/docs/sql-manual/basic-element/sql-data-types/date-time/TIMESTAMP-NS.md new file mode 100644 index 0000000000000..52b1b8e5ec497 --- /dev/null +++ b/docs/sql-manual/basic-element/sql-data-types/date-time/TIMESTAMP-NS.md @@ -0,0 +1,133 @@ +--- +{ + "title": "TIMESTAMP_NS", + "language": "en", + "description": "TIMESTAMP_NS stores a time-zone-naive date and time with fixed nanosecond precision." +} +--- + +## Description + +`TIMESTAMP_NS` stores a time-zone-naive date and time with fixed nanosecond precision. It is intended for event times, traces, and other data for which the microsecond precision of `DATETIME(6)` is insufficient. + +Internally, Doris stores the value as a signed 64-bit count of nanoseconds relative to the Unix epoch. Therefore, a `TIMESTAMP_NS` column occupies 8 bytes and has the following exact range: + +```text +[1677-09-21 00:12:43.145224192, 2262-04-11 23:47:16.854775807] +``` + +The output format is `yyyy-MM-dd HH:mm:ss.SSSSSSSSS`. All nine fractional-second digits are always displayed, including trailing zeros. + +Unlike `DATETIME(p)`, `TIMESTAMP_NS` has no configurable precision. Declarations such as `TIMESTAMP_NS(9)` are invalid. + +`TIMESTAMP_NS` can be used as a key column, partition column, bucket column, sequence column, and value column. It is also supported in `ARRAY`, `MAP`, `STRUCT`, and typed `VARIANT` values. + +## Syntax + +```sql +TIMESTAMP_NS +``` + +## Time Zone Semantics + +`TIMESTAMP_NS` does not store a time zone. Changing the session variable `time_zone` does not change a value after it has been stored. + +When an input string contains a time zone offset or name, Doris converts the input to the session or ingestion time zone while parsing it, and then stores the resulting local date and time without a time zone. When the input has no time zone, Doris stores its fields directly. + +Use [`TIMESTAMPTZ`](./TIMESTAMPTZ.md) instead when a value represents an instant that must be displayed in different session time zones. + +## Conversion and Operations + +Strings can contain up to nine fractional-second digits. If more digits are provided, Doris rounds to nanoseconds; a carry can propagate to the next second or date. Values outside the supported range are invalid. + +`TIMESTAMP_NS` supports conversions to and from numeric, character, `DATE`, `DATETIME`, `TIME`, `TIMESTAMPTZ`, and `VARIANT` types. Converting to a lower-precision temporal type rounds the value to the target precision. For complete rules, see [Cast to TIMESTAMP_NS](../conversion/timestamp-ns-conversion.md). + +Date-time extraction, formatting, arithmetic, comparison, aggregate, conditional, and window functions support `TIMESTAMP_NS`. Operations whose result remains `TIMESTAMP_NS` preserve all nine fractional-second digits. Operations that would leave the supported range report an error instead of wrapping. + +For nanosecond-specific operations, see [`NANOSECOND`](../../../sql-functions/scalar-functions/date-time-functions/nanosecond.md), [`NANOSECONDS_ADD`](../../../sql-functions/scalar-functions/date-time-functions/nanoseconds-add.md), [`NANOSECONDS_SUB`](../../../sql-functions/scalar-functions/date-time-functions/nanoseconds-sub.md), and [`NANOSECONDS_DIFF`](../../../sql-functions/scalar-functions/date-time-functions/nanoseconds-diff.md). + +## Examples + +Create a table and store nanosecond values: + +```sql +CREATE TABLE events ( + id BIGINT, + event_time TIMESTAMP_NS +) +DUPLICATE KEY(id) +DISTRIBUTED BY HASH(id) BUCKETS 1 +PROPERTIES ("replication_num" = "1"); + +INSERT INTO events VALUES + (1, '1970-01-01 00:00:00.000000001'), + (2, '2024-02-29 12:34:56.123456789'), + (3, NULL); + +SELECT * FROM events ORDER BY id; +``` + +```text ++------+-------------------------------+ +| id | event_time | ++------+-------------------------------+ +| 1 | 1970-01-01 00:00:00.000000001 | +| 2 | 2024-02-29 12:34:56.123456789 | +| 3 | NULL | ++------+-------------------------------+ +``` + +The tenth fractional digit is rounded to nanoseconds: + +```sql +SELECT CAST('1970-01-01 00:00:00.1234567895' AS TIMESTAMP_NS) AS ts; +``` + +```text ++-------------------------------+ +| ts | ++-------------------------------+ +| 1970-01-01 00:00:00.123456790 | ++-------------------------------+ +``` + +A time zone suffix is applied only while the input is parsed. The stored value remains unchanged after the session time zone changes: + +```sql +SET time_zone = '+08:00'; +CREATE TABLE timezone_example ( + id INT, + ts TIMESTAMP_NS +) +DUPLICATE KEY(id) +DISTRIBUTED BY HASH(id) BUCKETS 1 +PROPERTIES ("replication_num" = "1"); + +INSERT INTO timezone_example VALUES + (1, '2023-08-17T01:41:18.123456789Z'); + +SET time_zone = '+00:00'; +SELECT ts FROM timezone_example; +``` + +```text ++-------------------------------+ +| ts | ++-------------------------------+ +| 2023-08-17 09:41:18.123456789 | ++-------------------------------+ +``` + +`NULL` input returns `NULL`: + +```sql +SELECT CAST(NULL AS TIMESTAMP_NS) AS ts; +``` + +```text ++------+ +| ts | ++------+ +| NULL | ++------+ +``` diff --git a/docs/sql-manual/basic-element/sql-data-types/date-time/TIMESTAMPTZ.md b/docs/sql-manual/basic-element/sql-data-types/date-time/TIMESTAMPTZ.md index ee4c7efa2c3a9..9c9456c1f778b 100644 --- a/docs/sql-manual/basic-element/sql-data-types/date-time/TIMESTAMPTZ.md +++ b/docs/sql-manual/basic-element/sql-data-types/date-time/TIMESTAMPTZ.md @@ -15,7 +15,7 @@ In different database systems, time zone-aware timestamp types have various nami - SQL Server uses DATETIMEOFFSET - Some other databases use TIMESTAMP WITH LOCAL TIME ZONE -According to SQL standards, the standalone TIMESTAMP type should not carry time zone information (equivalent to TIMESTAMP WITHOUT TIME ZONE). Considering user habits and ease of use, Doris chose the more concise name TIMESTAMPTZ to represent the timestamp type with time zone. Note that currently Doris does not have a separate TIMESTAMP type, as users can effectively use DATETIME to store time information. +According to SQL standards, the standalone TIMESTAMP type should not carry time zone information (equivalent to TIMESTAMP WITHOUT TIME ZONE). Considering user habits and ease of use, Doris chose the more concise name TIMESTAMPTZ to represent the timestamp type with time zone. Doris does not have a standalone `TIMESTAMP` type: use `DATETIME` for a broad-range time-zone-naive value, or [`TIMESTAMP_NS`](./TIMESTAMP-NS.md) for a time-zone-naive value with fixed nanosecond precision. The range of TIMESTAMPTZ is the same as DATETIME, being `[0000-01-01 00:00:00.000000, 9999-12-31 23:59:59.999999]`. TIMESTAMPTZ supports specifying precision in the format TIMESTAMPTZ(p), where `p` represents the precision and can range from `[0, 6]`, with a default value of 0. In other words, TIMESTAMPTZ is equivalent to TIMESTAMPTZ(0). The default output format is `'yyyy-MM-dd HH:mm:ss.SSSSSS +XX:XX'`, where `+XX:XX` represents the time zone offset (note that the number of digits in `SSSSSS` is determined by the precision `p`). @@ -39,7 +39,7 @@ Therefore, TIMESTAMPTZ can be understood as a DATETIME type with time zone conve In Doris, a TIMESTAMPTZ type field occupies 8 bytes of storage space. -TIMESTAMPTZ and DATETIME types support mutual conversion, with appropriate time zone adjustments during conversion. TIMESTAMPTZ supports implicit conversion to DATETIME, allowing functions that do not directly support TIMESTAMPTZ to process this type of data. +TIMESTAMPTZ supports conversion to and from DATETIME and TIMESTAMP_NS, with appropriate time zone adjustments during conversion. TIMESTAMPTZ supports implicit conversion to DATETIME, allowing functions that do not directly support TIMESTAMPTZ to process this type of data. Converting TIMESTAMP_NS to TIMESTAMPTZ rounds from nanoseconds to the target TIMESTAMPTZ precision. ## Examples diff --git a/docs/sql-manual/basic-element/sql-data-types/semi-structured/ARRAY.md b/docs/sql-manual/basic-element/sql-data-types/semi-structured/ARRAY.md index c213730e092ab..0ec51624ff944 100644 --- a/docs/sql-manual/basic-element/sql-data-types/semi-structured/ARRAY.md +++ b/docs/sql-manual/basic-element/sql-data-types/semi-structured/ARRAY.md @@ -13,7 +13,7 @@ The `ARRAY` type is used to represent an ordered collection of elements, where each element has the same data type. For example, an array of integers can be represented as `[1, 2, 3]`, and an array of strings as `["a", "b", "c"]`. -- `ARRAY` represents an array composed of elements of type T, where T is nullable. Supported types for T include: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6, STRUCT, MAP, VARIANT, JSONB, ARRAY`. +- `ARRAY` represents an array composed of elements of type T, where T is nullable. Supported types for T include: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMP_NS, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6, STRUCT, MAP, VARIANT, JSONB, ARRAY`. - Note: Among the above T types, `JSONB` and `VARIANT` are only supported in the computation layer of Doris and **do not support using `ARRAY` and `ARRAY` in table creation in Doris**. ## Type Constraints @@ -25,7 +25,7 @@ The `ARRAY` type is used to represent an ordered collection of elements, wher - String type can be converted to `ARRAY` type (through parsing, returning NULL if parsing fails). - In the `AGGREGATE` table model, `ARRAY` type only supports `REPLACE` and `REPLACE_IF_NOT_NULL`. **In any table model, it cannot be used as a KEY column, nor as a partition or bucket column**. - Columns of `ARRAY` type **support `ORDER BY` and `GROUP BY` operations**. - - T types that support `ORDER BY` and `GROUP BY` include: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6`. + - T types that support `ORDER BY` and `GROUP BY` include: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMP_NS, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6`. - Columns of `ARRAY` type do not support being used as `JOIN KEY` and do not support being used in `DELETE` statements. ## Constant Construction @@ -180,7 +180,7 @@ select array(null) < array(-1), array(null) > array(-1); ## Query Acceleration - Columns of type `ARRAY` in Doris tables support adding inverted indexes to accelerate computations involving `ARRAY` functions on this column. - - T types supported by inverted indexes: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, DECIMAL, DATE, DATETIME, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6`. + - T types supported by inverted indexes: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, DECIMAL, DATE, DATETIME, TIMESTAMP_NS, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6`. - Accelerated `ARRAY` functions: `ARRAY_CONTAINS`, `ARRAYS_OVERLAP`, but when the function parameters include NULL, it falls back to regular vectorized computation. ## Examples @@ -327,4 +327,3 @@ select array(null) < array(-1), array(null) > array(-1); | 3 | [7, 8, 9] | +------+--------------+ ``` - diff --git a/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md b/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md index f110dcd13073f..93b55248d0d38 100644 --- a/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md +++ b/docs/sql-manual/basic-element/sql-data-types/semi-structured/MAP.md @@ -12,8 +12,8 @@ ## Type Description - The `MAP` type is used to represent a composite type of key-value pairs, where each key uniquely corresponds to a value. - - `key_type` represents the type of the keys, supporting types such as `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6`. Keys are nullable and cannot be specified as NOT NULL. - - `value_type` represents the type of the values, supporting `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6, ARRAY, MAP, STRUCT`. Values are nullable and cannot be specified as NOT NULL. + - `key_type` represents the type of the keys, supporting types such as `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMP_NS, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6`. Keys are nullable and cannot be specified as NOT NULL. + - `value_type` represents the type of the values, supporting `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMP_NS, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6, ARRAY, MAP, STRUCT`. Values are nullable and cannot be specified as NOT NULL. ## Type Constraints @@ -221,4 +221,3 @@ +---------------------+------------------------------+------+-------+---------+-------+ ``` - diff --git a/docs/sql-manual/basic-element/sql-data-types/semi-structured/STRUCT.md b/docs/sql-manual/basic-element/sql-data-types/semi-structured/STRUCT.md index b3f8b335e65ad..f9b04c2850d1f 100644 --- a/docs/sql-manual/basic-element/sql-data-types/semi-structured/STRUCT.md +++ b/docs/sql-manual/basic-element/sql-data-types/semi-structured/STRUCT.md @@ -17,7 +17,7 @@ The STRUCT type is used to combine multiple fields into a single structure, wher - `field_name` represents the name, **cannot be empty, cannot be duplicated, and is case-insensitive**. - - `field_type` represents the type, which is nullable and cannot be specified as NOT NULL. Supported types include: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6, ARRAY, MAP, STRUCT`. + - `field_type` represents the type, which is nullable and cannot be specified as NOT NULL. Supported types include: `BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMP_NS, TIMESTAMPTZ, CHAR, VARCHAR, STRING, IPV4, IPV6, ARRAY, MAP, STRUCT`. - `[COMMENT 'comment-string']` represents an optional comment. diff --git a/docs/sql-manual/basic-element/sql-data-types/semi-structured/VARIANT.md b/docs/sql-manual/basic-element/sql-data-types/semi-structured/VARIANT.md index 05f298de41071..1c4fa1cda88a3 100644 --- a/docs/sql-manual/basic-element/sql-data-types/semi-structured/VARIANT.md +++ b/docs/sql-manual/basic-element/sql-data-types/semi-structured/VARIANT.md @@ -113,7 +113,7 @@ CAST involving VARIANT has two directions: converting a supported SQL value to V | `TINYINT`, `SMALLINT`, `INT`, `BIGINT`, `LARGEINT` | Preserves the integer value. | | `FLOAT`, `DOUBLE` | Preserves the floating-point value. | | `DECIMALV2`, `DECIMAL(p, s)` with `p <= 38` | Preserves the Decimal value, subject to the limits below. | -| `DATE`, `DATETIME`, `TIMESTAMPTZ` | Preserves the typed logical value. | +| `DATE`, `DATETIME`, `TIMESTAMP_NS`, `TIMESTAMPTZ` | Preserves the typed logical value. | | `IPV4`, `IPV6` | Preserves the IP address value. | | `JSON` / `JSONB` | Converts the structured value directly to VARIANT. If the input contains a JSONB value type that VARIANT cannot represent, the BE returns an error. | | `ARRAY` | Converts each element recursively when `T` is `VARIANT` or is also in this whitelist, and preserves SQL NULL elements. | @@ -147,7 +147,7 @@ VARIANT can be cast to a compatible scalar, JSON/JSONB, or array target: | `TINYINT`, `SMALLINT`, `INT`, `BIGINT`, `LARGEINT` | Converts a compatible scalar root to the requested integer type. | | `FLOAT`, `DOUBLE` | Converts a compatible numeric root. | | `DECIMALV2`, `DECIMAL(p, s)` | Converts a compatible numeric root to the requested Decimal type. | -| `DATE`, `DATETIME`, `TIMESTAMPTZ` | Converts a compatible date/time root. | +| `DATE`, `DATETIME`, `TIMESTAMP_NS`, `TIMESTAMPTZ` | Converts a compatible date/time root. | | `CHAR`, `VARCHAR`, `STRING` | Returns scalar text for scalar roots and JSON text for objects and arrays. Variant/JSON `null` becomes the string `null`; outer SQL `NULL` remains SQL `NULL`. | | `IPV4`, `IPV6` | Converts a compatible IP address root to the requested IP address type. | | `JSON` / `JSONB` | Converts the value structurally. If the VARIANT value contains a type that JSON/JSONB cannot represent, the BE returns an error. | @@ -175,6 +175,7 @@ SELECT CAST(PARSE_TO_VARIANT('{"id": 1}') AS JSON) AS json_value; | `DATE` | Preserved as a calendar date with no time or time zone. | | Legacy `DATETIME` | Preserved with whole-second precision and no time-zone adjustment. | | `DATETIME(p)` | Supports `0 <= p <= 6` with no time-zone adjustment. | +| `TIMESTAMP_NS` | Preserves fixed nanosecond precision with no time-zone adjustment; values must be within the TIMESTAMP_NS range. | | `TIMESTAMPTZ(p)` | Supports `0 <= p <= 6` with time-zone-adjusted timestamp semantics. | | Decimal precision greater than 38 | Not supported as input to VARIANT. | | `TIME` | Not supported as input to VARIANT. | diff --git a/docs/sql-manual/sql-functions/aggregate-functions/any-value.md b/docs/sql-manual/sql-functions/aggregate-functions/any-value.md index 61f100f30c7f5..062a127dcf736 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/any-value.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/any-value.md @@ -25,7 +25,7 @@ ANY() | Parameter | Description | | -- | -- | -| `` | The column or expression to be aggregated. Supported types are String, Date, DateTime, Timestamptz, IPv4, IPv6, Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Array, Map, Struct, AggState, Bitmap, HLL, QuantileState. | +| `` | The column or expression to be aggregated. Supported types are String, Date, DateTime, TimestampNs, Timestamptz, IPv4, IPv6, Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Array, Map, Struct, AggState, Bitmap, HLL, QuantileState. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md b/docs/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md index f8e7582e6db61..f259e7fabc467 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md @@ -23,7 +23,7 @@ NDV() | Parameters | Description | | -- | -- | -| `` | The expression to get the value. Supported types are String, Date, DateTime,Timestamptz, IPv4, IPv6, TinyInt, Bool, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal. | +| `` | The expression to get the value. Supported types are String, Date, DateTime, TimestampNs, Timestamptz, IPv4, IPv6, TinyInt, Bool, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/array-agg.md b/docs/sql-manual/sql-functions/aggregate-functions/array-agg.md index cbc0610c1703e..f408c6b559076 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/array-agg.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/array-agg.md @@ -20,7 +20,7 @@ ARRAY_AGG() | Parameter | Description | | -- | -- | -| `` | An expression that determines the values to be placed into the array. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, Timestamptz, IPV4, IPV6, String, Array, Map, Struct. | +| `` | An expression that determines the values to be placed into the array. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, TimestampNs, Timestamptz, IPV4, IPV6, String, Array, Map, Struct. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/collect-list.md b/docs/sql-manual/sql-functions/aggregate-functions/collect-list.md index 514508f18a3f8..d28b6896209a1 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/collect-list.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/collect-list.md @@ -24,7 +24,7 @@ COLLECT_LIST( [,]) | Parameter | Description | | -- | -- | -| `` | An expression to determine the values to be placed into the array. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, Timestamptz, IPV4, IPV6, String, Array, Map, Struct. | +| `` | An expression to determine the values to be placed into the array. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, TimestampNs, Timestamptz, IPV4, IPV6, String, Array, Map, Struct. | | `` | Optional parameter to limit the result array size to max_size elements. Supported type: Integer. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/collect-set.md b/docs/sql-manual/sql-functions/aggregate-functions/collect-set.md index ff1ce2bcd9881..6754686f19737 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/collect-set.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/collect-set.md @@ -24,7 +24,7 @@ COLLECT_SET( [,]) | Parameter | Description | | -- | -- | -| `` | An expression to determine the values to be placed into the array. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, Timestamptz, IPV4, IPV6, String, Array, Map, Struct. | +| `` | An expression to determine the values to be placed into the array. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, TimestampNs, Timestamptz, IPV4, IPV6, String, Array, Map, Struct. | | `` | Optional parameter to limit the result array size to max_size elements. Supported type: Integer. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/histogram.md b/docs/sql-manual/sql-functions/aggregate-functions/histogram.md index 2e54c26b1be29..cc3d3f0fe530f 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/histogram.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/histogram.md @@ -25,7 +25,7 @@ HIST([, ]) | Parameters | Description | | -- | -- | -| `expr` | The expression to be calculated. Supported types: TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, String. | +| `expr` | The expression to calculate. Supported types: TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, TimestampNs, and Timestamptz. | | `num_buckets` | Optional. Limit the number of histogram buckets. The default value is 128. Supported type: Integer.| diff --git a/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md b/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md index d12878d93722c..c00fb38bc712d 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md @@ -18,8 +18,8 @@ The MAP_AGG function is used to form a mapping structure based on key-value pair | Parameter | Description | | -- | -- | -| `` | The expression used as the key. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, String. | -| `` | The expression used as the value. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, String. | +| `` | The expression used as the key. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, TimestampNs, Timestamptz, and String. | +| `` | The expression used as the value. Supported types: Bool, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, TimestampNs, Timestamptz, and String. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/max-by.md b/docs/sql-manual/sql-functions/aggregate-functions/max-by.md index f909435a89867..08c9eb52f3241 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -20,8 +20,8 @@ MAX_BY(, ) | Parameter | Description | | -- | -- | -| `` | The expression for the associated value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, Array, Map, Struct. | -| `` | The expression for the maximum value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, Array. | +| `` | The expression for the associated value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, TimestampNs, Array, Map, Struct. | +| `` | The expression for the maximum value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, TimestampNs, Array. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/max.md b/docs/sql-manual/sql-functions/aggregate-functions/max.md index 1584a4bdf5682..7c341ea66c67d 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/max.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/max.md @@ -20,7 +20,7 @@ MAX() | Parameters | Description | | -- | -- | -| `` | The expression to get the value. Supported types are String, Time, Date, DateTime, Timestamptz, IPv4, IPv6, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Array. | +| `` | The expression to get the value. Supported types are String, Time, Date, DateTime, TimestampNs, Timestamptz, IPv4, IPv6, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Array. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/min-by.md b/docs/sql-manual/sql-functions/aggregate-functions/min-by.md index c1a4a7d1b5c47..d0564ccfeef1a 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -20,8 +20,8 @@ MIN_BY(, ) | Parameter | Description | | -- | -- | -| `` | The expression for the associated value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, Array, Map, Struct. | -| `` | The expression for the minimum value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, Array. | +| `` | The expression for the associated value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, TimestampNs, Array, Map, Struct. | +| `` | The expression for the minimum value, supports types: Bool, TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal, String, Date, Datetime, TimestampNs, Array. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/min.md b/docs/sql-manual/sql-functions/aggregate-functions/min.md index 836a00ebb27e1..3c01dcbcef9be 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/min.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/min.md @@ -20,7 +20,7 @@ MIN() | Parameters | Description | | -- | -- | -| `` | The expression to get the value. Supported types are String, Time, Date, DateTime, Timestamptz, IPv4, IPv6, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Array. | +| `` | The expression to get the value. Supported types are String, Time, Date, DateTime, TimestampNs, Timestamptz, IPv4, IPv6, TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Array. | ## Return Value diff --git a/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md b/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md index dca842dd882ea..3ef770cbe3633 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md @@ -25,7 +25,7 @@ SEQUENCE_COUNT(, , [, , ..., ]); | Parameter | Description | | -- | -- | | `` | Pattern string, see **Pattern syntax** below. Supports type String. | -| `` | Column considered to contain time data. Supports type Date, DateTime. | +| `` | Column considered to contain time data. Supports type Date, DateTime, TimestampNs. | | `` | Conditions that describe the chain of events. Supports type Bool. Up to 32 condition arguments can be passed. The function takes only the events described in these conditions into account. If the sequence contains data that isn't described in a condition, the function skips them. | **Pattern syntax** diff --git a/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md b/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md index b78a1875d7fd9..5e800ecd46fd1 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md @@ -26,7 +26,7 @@ SEQUENCE_MATCH(, , [, , ..., ]) | Parameter | Description | | -- | -- | | `` | Pattern string. See **Pattern syntax** below. Supports type String. | -| `` | Column considered to contain time data. Supports type Date, DateTime. | +| `` | Column considered to contain time data. Supports type Date, DateTime, TimestampNs. | | `` | Conditions that describe the chain of events. Supports type Bool. Up to 32 condition arguments can be passed. The function takes only the events described in these conditions into account. If the sequence contains data that isn't described in a condition, the function skips them. | **Pattern syntax** diff --git a/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md b/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md index 2fcd3a0eb40bc..5f107dd5589a7 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md @@ -20,7 +20,7 @@ TOPN_ARRAY(, [, ]) | Parameter | Description | | -- | -- | -| `` | The column or expression to be counted. Supported types: TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, IPV4, IPV6, String. | +| `` | The column or expression to be counted. Supported types: TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, TimestampNs, Timestamptz, IPV4, IPV6, String. | | `` | The number of most frequent values to return. Must be a positive integer. Supported type: Integer. | | `` | Optional. Sets the number of counters used in the Space-Saving algorithm: `counter_numbers = top_num * space_expand_rate`. The larger the value, the more accurate the result. Default is 50. Supported type: Integer. | diff --git a/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md b/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md index ba843f87a66bc..38decef6e437f 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md @@ -20,7 +20,7 @@ TOPN_WEIGHTED(, , [, ]) | Parameter | Description | | -- | -- | -| `` | The column or expression to be counted. Supported types: TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, IPV4, IPV6, String. | +| `` | The column or expression to be counted. Supported types: TinyInt, SmallInt, Integer, BigInt, LargeInt, Float, Double, Decimal, Date, Datetime, TimestampNs, IPV4, IPV6, String. | | `` | The column or expression used to adjust the weight. Supported type: Double.| | `` | The number of most frequent values to return. Must be a positive integer. Supported type: Integer. | | `` | Optional. Sets the number of counters used in the Space-Saving algorithm: `counter_numbers = top_num * space_expand_rate`. The larger the value, the more accurate the result. Default is 50. Supported type: Integer. | diff --git a/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md b/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md index c9d3acda46dbb..80a2f4bbae810 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md @@ -28,7 +28,7 @@ WINDOW_FUNNEL(, , , [, event_2, ... , event_n] | -- | -- | | `` | window is the length of time window in seconds | | `` | There are four modes in total, `default`, `deduplication`, `fixed`, and `increase`. For details, please refer to the **Mode** below. | -| `` | timestamp specifies column of DATETIME type, sliding time window works on it | +| `` | Timestamp column used by the sliding window. Supports `DATE`, `DATETIME`, `TIMESTAMP_NS`, and `TIMESTAMPTZ`. | | `` | evnet_n is boolean expression like eventID = 1004 | **Mode** diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-apply.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-apply.md index 0686b718c5d5d..4ac9d34f939a4 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-apply.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-apply.md @@ -31,7 +31,7 @@ array_apply(arr, op, val) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN ### Return Value @@ -179,4 +179,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = class org.apache.doris.nereids. ### Keywords -ARRAY, APPLY, ARRAY_APPLY \ No newline at end of file +ARRAY, APPLY, ARRAY_APPLY diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-compact.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-compact.md index f7ee2b277ecf2..65ba48fea43e7 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-compact.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-compact.md @@ -30,7 +30,7 @@ array_compact(ARRAY arr) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex data types: ARRAY @@ -172,4 +172,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the compatibility ### Keywords -ARRAY, COMPACT, ARRAY_COMPACT \ No newline at end of file +ARRAY, COMPACT, ARRAY_COMPACT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-concat.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-concat.md index a67c7e0772c4f..dd93d50d4df7a 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-concat.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-concat.md @@ -30,7 +30,7 @@ array_concat(ARRAY arr1, [ARRAY arr2, ...]) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex data types: ARRAY, MAP, STRUCT @@ -197,4 +197,4 @@ Ensure that all input array element types are compatible, especially for nested ### Keywords -ARRAY, CONCAT, ARRAY_CONCAT \ No newline at end of file +ARRAY, CONCAT, ARRAY_CONCAT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-contains.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-contains.md index 2a2a33b8573fc..aee0c19b44699 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-contains.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-contains.md @@ -31,7 +31,7 @@ array_contains(ARRAY arr, T value) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 @@ -68,7 +68,7 @@ Return value behavior description: - CHAR, VARCHAR, STRING types can be compared with each other 3. **Date and time type compatibility**: - DATE and DATEV2 can be compared with each other - - DATETIME and DATETIMEV2 can be compared with each other + - DATETIME, DATETIMEV2, and TIMESTAMP_NS can be compared with each other. Mixed DATETIME and TIMESTAMP_NS values use TIMESTAMP_NS as the common type. ### Examples diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md index a65101d671596..242da5283bdeb 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md @@ -30,7 +30,7 @@ array_count(lambda, array1, ...) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex data types: ARRAY, MAP, STRUCT @@ -195,4 +195,4 @@ SELECT array_count(x -> x % 2 = 0, [1, 2, 3, 4, 5, 6]); ### Keywords -ARRAY, COUNT, ARRAY_COUNT \ No newline at end of file +ARRAY, COUNT, ARRAY_COUNT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-distinct.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-distinct.md index ed857acaf106f..3dc4092e4c549 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-distinct.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-distinct.md @@ -29,7 +29,7 @@ array_distinct(ARRAY arr) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 @@ -166,4 +166,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the compatibility ### Keywords -ARRAY, DISTINCT, ARRAY_DISTINCT \ No newline at end of file +ARRAY, DISTINCT, ARRAY_DISTINCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate-uniq.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate-uniq.md index 518216764edc3..cab14107507d8 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate-uniq.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate-uniq.md @@ -29,7 +29,7 @@ array_enumerate_uniq(ARRAY arr1, [ARRAY arr2, ...]) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate.md index 0f52720907131..b800187d0706a 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-enumerate.md @@ -29,7 +29,7 @@ array_enumerate(ARRAY arr) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except.md index c8ff6e7a2ef2b..d6ca8e5662d2e 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-except.md @@ -30,7 +30,7 @@ array_except(ARRAY arr1, ARRAY arr2) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 @@ -217,4 +217,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the compatibility ### Keywords -ARRAY, EXCEPT, ARRAY_EXCEPT \ No newline at end of file +ARRAY, EXCEPT, ARRAY_EXCEPT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-exists.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-exists.md index dff34d01ea8b3..f0934efcbc530 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-exists.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-exists.md @@ -30,7 +30,7 @@ array_exists(lambda, array1, ...) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex data types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-filter.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-filter.md index 6aa1997e7e186..5b9300f8b0a39 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-filter.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-filter.md @@ -32,7 +32,7 @@ array_filter(array1, array filter_array) **T supported types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex data types: ARRAY, MAP, STRUCT @@ -254,4 +254,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the compatibility ### Keywords -ARRAY, FILTER, ARRAY_FILTER \ No newline at end of file +ARRAY, FILTER, ARRAY_FILTER diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first-index.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first-index.md index 21f310e7f0d86..dea5c868e7014 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first-index.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first-index.md @@ -30,7 +30,7 @@ array_first_index(lambda, array1, ...) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex data types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first.md index b8900b95abd5d..a69c9b8276930 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-first.md @@ -30,7 +30,7 @@ array_first(lambda, array1, ...) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex data types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-intersect.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-intersect.md index 440f0a9bdae5a..fb5d8b08b65cf 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-intersect.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-intersect.md @@ -29,7 +29,7 @@ array_intersect(ARRAY arr1, ARRAY arr2, [ARRAY arr3, ...]) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-join.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-join.md index 32c995c164026..92a9636a5be0f 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-join.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-join.md @@ -31,7 +31,7 @@ array_join(ARRAY arr, STRING separator [, STRING null_replacement]) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last-index.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last-index.md index 448fc36f890b6..33254b5ad4be1 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last-index.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last-index.md @@ -30,7 +30,7 @@ array_last_index(lambda, ARRAY arr1, [ARRAY arr2, ...]) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last.md index d77de089dfae5..00de89a1aa2fa 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-last.md @@ -30,7 +30,7 @@ array_last(lambda, ARRAY arr1, [ARRAY arr2, ...]) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-map.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-map.md index 04befe89de599..e6e32ae40de04 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-map.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-map.md @@ -30,7 +30,7 @@ array_map(lambda, ARRAY arr1, [ARRAY arr2, ...]) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-max.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-max.md index 3a0757cc88638..986f1e9ce5ad4 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-max.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-max.md @@ -29,7 +29,7 @@ array_max(ARRAY arr) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-min.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-min.md index d7d5f45e58374..0a06eed9836ee 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-min.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-min.md @@ -29,7 +29,7 @@ array_min(ARRAY arr) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popback.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popback.md index 6b8c071af5686..978cbef4f0568 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popback.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popback.md @@ -29,7 +29,7 @@ array_popback(ARRAY arr) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popfront.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popfront.md index 9a3f05eb5d184..507e37228bb78 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popfront.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-popfront.md @@ -29,7 +29,7 @@ array_popfront(ARRAY arr) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-position.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-position.md index 8942e0d60f8cb..84b6e7b1cfb09 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-position.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-position.md @@ -30,7 +30,7 @@ array_position(ARRAY arr, T element) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushback.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushback.md index d38d16c814ca3..205e574a76c81 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushback.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushback.md @@ -34,7 +34,7 @@ array_pushback(ARRAY arr, T element) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushfront.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushfront.md index 997011906f919..135f6298ba578 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushfront.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-pushfront.md @@ -30,7 +30,7 @@ array_pushfront(ARRAY arr, T element) **Supported types for T:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md index 2e9c215cf6449..2dab11989b91c 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-range.md @@ -24,13 +24,13 @@ Generate an arithmetic sequence array of numbers or datetimes. - `start`, `end`: non-negative integers. `end` is the upper bound and is excluded from the result. - `step`: must be a positive integer; the step length; default is 1. -- `start_dt`, `end_dt`: DATETIME. In the two-argument form, the default step is 1 DAY. +- `start_dt`, `end_dt`: `DATETIME` or `TIMESTAMP_NS`. Both arguments must have the same type. In the two-argument form, the default step is 1 DAY. - `interval step unit`: datetime step. `unit` can be `YEAR|QUARTER|MONTH|WEEK|DAY|HOUR|MINUTE|SECOND`; `step` must be a positive integer. ## Return value - Returns `ARRAY`; returns `NULL` for illegal arguments; returns an empty array `[]` for an empty range. -- The element type `T` matches the input: integers produce `INT`, datetimes produce `DATETIME`. +- The element type `T` matches the input: integers produce `INT`; `DATETIME` and `TIMESTAMP_NS` inputs produce the corresponding temporal type. ## Usage notes @@ -71,3 +71,5 @@ Generate an arithmetic sequence array of numbers or datetimes. - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 12:02:00', interval 1 minute)` -> `["2022-05-15 12:00:00", "2022-05-15 12:01:00"]` - `ARRAY_RANGE('2022-05-15 12:00:00', '2022-05-15 12:00:02', interval 1 second)` -> `["2022-05-15 12:00:00", "2022-05-15 12:00:01"]` +- `TIMESTAMP_NS` preserves nanosecond precision in the generated elements. + - `ARRAY_RANGE(CAST('2022-05-15 12:00:00.123456789' AS TIMESTAMP_NS), CAST('2022-05-15 12:00:02.123456789' AS TIMESTAMP_NS), INTERVAL 1 SECOND)` -> `["2022-05-15 12:00:00.123456789", "2022-05-15 12:00:01.123456789"]` diff --git a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array.md b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array.md index c4b604173b89f..7759fcd9f6276 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array.md +++ b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array.md @@ -32,7 +32,7 @@ array([element1, element2, ...]) **Supported element types:** - Numeric types: TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL - String types: CHAR, VARCHAR, STRING -- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2 +- Date and time types: DATE, DATETIME, DATEV2, DATETIMEV2, TIMESTAMP_NS - Boolean type: BOOLEAN - IP types: IPV4, IPV6 - Complex types: ARRAY, MAP, STRUCT @@ -139,4 +139,3 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the compatibility ### Keywords ARRAY - diff --git a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/coalesce.md b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/coalesce.md index 112c0b03f8b7b..921d5d2722fce 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/coalesce.md +++ b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/coalesce.md @@ -32,7 +32,7 @@ Returns the first non-null expression in the argument list. If all arguments are * String types (String/VARCHAR/CHAR) * Boolean type (Boolean) * Numeric types (TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal) - * Date types (Date, DateTime) + * Date types (Date, DateTime, TimestampNs) * Bitmap type (Bitmap) * Semi-structured types (JSON, Array, MAP, Struct) diff --git a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/greatest.md b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/greatest.md index d5128a9413356..114197ceb0c30 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/greatest.md +++ b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/greatest.md @@ -18,7 +18,7 @@ GREATEST( [, ...]) ## Parameters ### Required Parameter -- ``: Supports `TINYINT`, `SMALLINT`, `INT`, `BIGINT`, `LARGEINT`, `FLOAT`, `DOUBLE`, `STRING`, `DATETIME`, and `DECIMAL` types. +- ``: Supports `TINYINT`, `SMALLINT`, `INT`, `BIGINT`, `LARGEINT`, `FLOAT`, `DOUBLE`, `STRING`, `DATETIME`, `TIMESTAMP_NS`, and `DECIMAL` types. ### Optional Parameters - Supports multiple arguments. @@ -75,4 +75,4 @@ GREATEST( [, ...]) +-------------------------------------------------------------------------------+ | 2022-02-26 20:02:11 | +-------------------------------------------------------------------------------+ - ``` \ No newline at end of file + ``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/least.md b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/least.md index 9e90afeaceec3..ce89283e6d7db 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/least.md +++ b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/least.md @@ -18,7 +18,7 @@ LEAST( [, ...]) ## Parameters ### Required Parameter -- ``: Supports `TINYINT`, `SMALLINT`, `INT`, `BIGINT`, `LARGEINT`, `FLOAT`, `DOUBLE`, `STRING`, `DATETIME`, and `DECIMAL` types. +- ``: Supports `TINYINT`, `SMALLINT`, `INT`, `BIGINT`, `LARGEINT`, `FLOAT`, `DOUBLE`, `STRING`, `DATETIME`, `TIMESTAMP_NS`, and `DECIMAL` types. ### Optional Parameters - Supports multiple arguments. @@ -76,4 +76,4 @@ LEAST( [, ...]) +----------------------------------------------------------------------------+ | 2020-01-23 20:02:11 | +----------------------------------------------------------------------------+ - ``` \ No newline at end of file + ``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/nullif.md b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/nullif.md index bf0d3df466bba..2ea4ca4a1fd62 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/nullif.md +++ b/docs/sql-manual/sql-functions/scalar-functions/conditional-functions/nullif.md @@ -31,7 +31,7 @@ NULLIF(, ) Supported types for parameters: 1. Boolean 2. Numeric types (TinyInt, SmallInt, Int, BigInt, LargeInt, Float, Double, Decimal) -3. Date types (Date, DateTime, Time) +3. Date types (Date, DateTime, TimestampNs, Time) 4. String types (String, VARCHAR, CHAR) ## Return Value @@ -60,4 +60,4 @@ Supported types for parameters: +--------------+ | 1 | +--------------+ - ``` \ No newline at end of file + ``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md index c03150f8825b9..7386e947eddfe 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md @@ -20,11 +20,13 @@ ADD_TIME(``, `