From 02e2c98e05bc1a8b49246ae514f2f276bbe54e28 Mon Sep 17 00:00:00 2001 From: Anton Bobkov Date: Mon, 22 Sep 2025 15:56:05 +0300 Subject: [PATCH 1/4] First draft --- .../en/core/yql/reference/types/primitive.md | 521 +++++++++++++----- .../core/yql/reference/udf/list/datetime.md | 325 ++++++----- 2 files changed, 584 insertions(+), 262 deletions(-) diff --git a/ydb/docs/en/core/yql/reference/types/primitive.md b/ydb/docs/en/core/yql/reference/types/primitive.md index 2d7d5c3bbc7d..dcfeaa72ea34 100644 --- a/ydb/docs/en/core/yql/reference/types/primitive.md +++ b/ydb/docs/en/core/yql/reference/types/primitive.md @@ -6,39 +6,98 @@ The terms "simple", "primitive", and "elementary" data types are used synonymous ## Numeric types {#numeric} -| Type | Description | Notes | -| ----- | ----- | ----- | -| `Bool` | Boolean value. | — | -| `Int8` | A signed integer.
Acceptable values: from -27 to 27–1. | — | -| `Int16` | A signed integer.
Acceptable values: from –215 to 215–1. | — | -| `Int32` | A signed integer.
Acceptable values: from –231 to 231–1. | — | -| `Int64` | A signed integer.
Acceptable values: from –263 to 263–1. | — | -| `Uint8` | An unsigned integer.
Acceptable values: from 0 to 28–1. | — | -| `Uint16` | An unsigned integer.
Acceptable values: from 0 to 216–1. | — | -| `Uint32` | An unsigned integer.
Acceptable values: from 0 to 232–1. | — | -| `Uint64` | An unsigned integer.
Acceptable values: from 0 to 264–1. | — | -| `Float` | A real number with variable precision, 4 bytes in size. | {% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index{% endif %} | -| `Double` | A real number with variable precision, 8 bytes in size. | {% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index{% endif %} | -| `Decimal(precision, scale)` | A real number with the specified precision, 16 bytes in size. Precision is the maximum total number of decimal digits stored and can range from 1 to 35. Scale is the maximum number of decimal digits stored to the right of the decimal point and can range from 0 to the precision value. | {% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index{% endif %} | +#| +|| Type | +Description | +Notes + || +|| `Bool` | +Boolean value | + || +|| `Int8` | +Signed integer +| Acceptable values: from –27 to 27–1 | + || +|| `Int16` | +Signed integer +| Acceptable values: from –215 to 215–1 | + || +|| `Int32` | +Signed integer +| Acceptable values: from –231 to 231–1 | + || +|| `Int64` | +Signed integer +| Acceptable values: from –263 to 263–1 | + || +|| `Uint8` | +Unsigned integer +| Acceptable values: from 0 to 28–1 | + || +|| `Uint16` | +Unsigned integer +| Acceptable values: from 0 to 216–1 | + || +|| `Uint32` | +Unsigned integer +| Acceptable values: from 0 to 232–1 | + || +|| `Uint64` | +Unsigned integer +| Acceptable values: from 0 to 264–1 | + || +|| `Float` | +Real number with variable precision, 4 bytes in size | +{% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index{% endif %} + || +|| `Double` | +Real number with variable precision, 8 bytes in size | +{% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index{% endif %} + || +|| `Decimal(precision, scale)` | +Real number with fixed precision, 16 bytes in size. Precision is the maximum total number of decimal digits stored, takes values from 1 to 35. Scale is the maximum number of decimal digits stored to the right of the decimal point, takes values from 0 to the precision value. | +{% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index{% endif %} + || {% if feature_map_tables %} -|`DyNumber` | A binary representation of a real number with an accuracy of up to 38 digits.
Acceptable values: positive numbers from 1×10-130 up to 1×10126–1, negative numbers from -1×10126–1 to -1×10-130, and 0.
Compatible with the `Number` type in AWS DynamoDB. It's not recommended for {{ backend_name_lower }}-native applications. | — | +|| `DyNumber` | +Binary representation of a real number with precision up to 38 digits. +| Acceptable values: positive from 1×10-130 to 1×10126–1, negative from -1×10126–1 to -1×10-130 and 0. +Compatible with the `Number` type in AWS DynamoDB. Not recommended for use in {{ backend_name_lower }}-native applications. | + || {% endif %} +|# ## String types {#string} -| Type | Description | Notes | -| ----- | ----- | ----- | -| `String` | A string that can contain any binary data | — | -| `Utf8` | Text encoded in [UTF-8](https://en.wikipedia.org/wiki/UTF-8) | — | -| `Json` | [JSON](https://en.wikipedia.org/wiki/JSON) represented as text | Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} | -| `JsonDocument` | [JSON](https://en.wikipedia.org/wiki/JSON) in an indexed binary representation | Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} | -| `Yson` | [YSON](../udf/list/yson.md) in a textual or binary representation. | Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} | -| `Uuid` | Universally unique identifier [UUID](https://tools.ietf.org/html/rfc4122) | — | - -{% note info "Cell size restrictions" %} - -The maximum value size for a {% if feature_map_tables %}non-key {% endif %} column cell with any string data type is 8 MB. +#| +|| Type | Description | Notes || +|| `String` | +String, can contain arbitrary binary data | + || +|| `Utf8` | +Text in [UTF-8](https://en.wikipedia.org/wiki/UTF-8) encoding | + || +|| `Json` | +[JSON](https://en.wikipedia.org/wiki/JSON) in textual representation | +Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} + || +|| `JsonDocument` | +[JSON](https://en.wikipedia.org/wiki/JSON) in binary indexed representation | +Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} + || +|| `Yson` | +[YSON](yson.md) in textual or binary representation | +Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} + || +|| `Uuid` | +Universal identifier [UUID](https://tools.ietf.org/html/rfc4122) | + || +|# + +{% note info "Size restrictions" %} + +Maximum value size in a cell {% if feature_map_tables %} of a non-key column {% endif %} with any string data type — 8 MB. {% endnote %} @@ -58,40 +117,202 @@ To store numbers (JSON Number) in `JsonDocument`, as well as for arithmetic oper ## Date and time {#datetime} -| Type | Description | Notes | -| ----- | ----- | ----- | -| `Date` | Date, precision to the day | Range of values for all time types except `Interval`: From 00:00 01.01.1970 to 00:00 01.01.2106. Internal `Date` representation: Unsigned 16-bit integer | -| `Datetime` | Date/time, precision to the second | Internal representation: Unsigned 32-bit integer | -| `Timestamp` | Date/time, precision to the microsecond | Internal representation: Unsigned 64-bit integer | -| `Interval` | Time interval (signed), precision to microseconds | Value range: From -136 years to +136 years. Internal representation: Signed 64-bit integer. {% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index{% endif %} | -| `TzDate` | Date with time zone label, precision to the day | Not supported in table columns | -| `TzDateTime` | Date/time with time zone label, precision to the second | Not supported in table columns | -| `TzTimestamp` | Date/time with time zone label, precision to the microsecond | Not supported in table columns | - - - -### Supporting types with a time zone label - -Time zone label for the `TzDate`, `TzDatetime`, `TzTimestamp` types is an attribute that is used: +#| +|| Type | Description | Possible values | Size (bytes) | Notes || + +|| +`Date` +| +A moment in time corresponding to midnight1 in UTC, precision to the day +| +from 00:00 01.01.1970 to 00:00 01.01.2106 +| +4 +| +— +|| + +|| +`Date32` +| +A moment in time corresponding to midnight1 in UTC, precision to the day +| +from 00:00 01.01.144169 BC to 00:00 01.01.148107 AD +| +4 +| +— +|| + +|| +`Datetime` +| +A moment in time in UTC, precision to the second +| +from 00:00 01.01.1970 to 00:00 01.01.2106 +| +4 +| +— +|| + +|| +`Datetime64` +| +A moment in time in UTC, precision to the second +| +from 00:00 01.01.144169 BC to 00:00 01.01.148107 AD +| +8 +| +— +|| + +|| +`Timestamp` +| +A moment in time in UTC, precision to the microsecond +| +from 00:00 01.01.1970 to 00:00 01.01.2106 +| +8 +| +— +|| + +|| +`Timestamp64` +| +A moment in time in UTC, precision to the microsecond +| +from 00:00 01.01.144169 BC to 00:00 01.01.148107 AD +| +8 +| +— +|| + +|| +`Interval` +| +Time interval, precision to the microsecond +| +from -136 years to +136 years +| +8 +| +{% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index.{% else %}—{% endif %} +|| + +|| +`Interval64` +| +Time interval, precision to the microsecond +| +from -292277 years to +292277 years +| +8 +| +— +|| + +|| +`TzDate` +| +A moment in time in UTC corresponding to midnight in the specified timezone +| +from 00:00 01.01.1970 to 00:00 01.01.2106 +| + +| +Not supported in table columns +|| + +|| +`TzDate32` +| +A moment in time in UTC corresponding to midnight in the specified timezone +| +from 00:00 01.01.144169 BC to 00:00 01.01.148107 AD +| +4 and timezone label +| +— +|| + +|| +`TzDateTime` +| +A moment in time in UTC with timezone label and precision to the second +| +from 00:00 01.01.1970 to 00:00 01.01.2106 +| + +| +Not supported in table columns +|| + +|| +`TzDateTime64` +| +A moment in time in UTC with timezone label and precision to the second +| +from 00:00 01.01.144169 BC to 00:00 01.01.148107 AD +| +8 and timezone label +| +— +|| + +|| +`TzTimestamp` +| +A moment in time in UTC with timezone label and precision to the microsecond +| +from 00:00 01.01.1970 to 00:00 01.01.2106 +| + +| +Not supported in table columns +|| + +|| +`TzTimestamp64` +| +A moment in time in UTC with timezone label and precision to the microsecond +| +from 00:00 01.01.144169 BC to 00:00 01.01.148107 AD +| +8 and timezone label +| +— +|| +|# + +1 Midnight refers to the time point where all _time_ components equal zero. + +### Features of supporting types with timezone label + +Timezone label for the `TzDate`, `TzDatetime`, `TzTimestamp` types is an attribute that is used: * When converting ([CAST](../syntax/expressions.md#cast), [DateTime::Parse](../udf/list/datetime.md#parse), [DateTime::Format](../udf/list/datetime.md#format)) to a string and from a string. -* In [DateTime::Split](../udf/list/datetime.md#split), a timezone component is added to `Resource`. +* In [DateTime::Split](../udf/list/datetime.md#split) - a timezone component appears in `Resource`. -The point in time for these types is stored in UTC, and the timezone label doesn't participate in any other calculations in any way. For example: +The actual time position value for these types is stored in UTC, and the timezone label doesn't participate in other calculations in any way. For example: ```yql -SELECT -- these expressions are always true for any timezones: the timezone doesn't affect the point in time. +SELECT --these expressions are always true for any timezones: timezone doesn't affect the point in time. AddTimezone(CurrentUtcDate(), "Europe/Moscow") == AddTimezone(CurrentUtcDate(), "America/New_York"), AddTimezone(CurrentUtcDatetime(), "Europe/Moscow") == AddTimezone(CurrentUtcDatetime(), "America/New_York"); ``` -Keep in mind that when converting between `TzDate` and `TzDatetime`, or `TzTimestamp` the date's midnight doesn't follow the local time zone, but midnight in UTC for the date in UTC. +It's important to understand that when converting between `TzDate` and `TzDatetime` or `TzTimestamp`, the date corresponds not to midnight in the local timezone time, but to midnight in UTC for the date in UTC. -## Casting between data types {#cast} +## Simple data types casting {#cast} ### Explicit casting {#explicit-cast} @@ -99,77 +320,101 @@ Explicit casting using [CAST](../syntax/expressions.md#cast): #### Casting to numeric types -| Type | Bool | Int8 | Int16 | Int32 | Int64 | Uint8 | Uint16 | Uint32 | Uint64 | Float | Double | Decimal | -|---------------|-----------------|-----------------|-----------------|-----------------|-----------------|-------------------|-------------------|-------------------|-------------------|-----------------|-----------------|---------| -| **Bool** | — | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | No | -| **Int8** | Yes2 | — | Yes | Yes | Yes | Yes3 | Yes3 | Yes3 | Yes3 | Yes | Yes | Yes | -| **Int16** | Yes2 | Yes4 | — | Yes | Yes | Yes3,4 | Yes3 | Yes3 | Yes3 | Yes | Yes | Yes | -| **Int32** | Yes2 | Yes4 | Yes4 | — | Yes | Yes3,4 | Yes3,4 | Yes3 | Yes3 | Yes | Yes | Yes | -| **Int64** | Yes2 | Yes4 | Yes4 | Yes4 | — | Yes3,4 | Yes3,4 | Yes3,4 | Yes3 | Yes | Yes | Yes | -| **Uint8** | Yes2 | Yes4 | Yes | Yes | Yes | — | Yes | Yes | Yes | Yes | Yes | Yes | -| **Uint16** | Yes2 | Yes4 | Yes4 | Yes | Yes | Yes4 | — | Yes | Yes | Yes | Yes | Yes | -| **Uint32** | Yes2 | Yes4 | Yes4 | Yes4 | Yes | Yes4 | Yes4 | — | Yes | Yes | Yes | Yes | -| **Uint64** | Yes2 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | — | Yes | Yes | Yes | -| **Float** | Yes2 | Yes4 | Yes4 | Yes4 | Yes4 | Yes3,4 | Yes3,4 | Yes3,4 | Yes3,4 | — | Yes | No | -| **Double** | Yes2 | Yes4 | Yes4 | Yes4 | Yes4 | Yes3,4 | Yes3,4 | Yes3,4 | Yes3,4 | Yes | — | No | -| **Decimal** | No | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | — | -| **String** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | -| **Utf8** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | -| **Json** | No | No | No | No | No | No | No | No | No | No | No | No | -| **Yson** | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | No | -| **Uuid** | No | No | No | No | No | No | No | No | No | No | No | No | -| **Date** | No | Yes4 | Yes4 | Yes | Yes | Yes4 | Yes | Yes | Yes | Yes | Yes | No | -| **Datetime** | No | Yes4 | Yes4 | Yes4 | Yes | Yes4 | Yes4 | Yes | Yes | Yes | Yes | No | -| **Timestamp** | No | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes | Yes | Yes | No | -| **Interval** | No | Yes4 | Yes4 | Yes4 | Yes | Yes3,4 | Yes3,4 | Yes3,4 | Yes3 | Yes | Yes | No | - -1 `True` is converted to `1` and `False` to `0`. +| Type | Bool | Int8 | Int16 | Int32 | Int64 | Uint8 | Uint16 | Uint32 | Uint64 | Float | Double | Decimal | +| --------------- | -------------- | -------------- | -------------- | -------------- | -------------- | ---------------- | ---------------- | ---------------- | ---------------- | -------------- | -------------- | ------- | +| **Bool** | — | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | Yes1 | No | +| **Int8** | Yes2 | — | Yes | Yes | Yes | Yes3 | Yes3 | Yes3 | Yes3 | Yes | Yes | Yes | +| **Int16** | Yes2 | Yes4 | — | Yes | Yes | Yes3,4 | Yes3 | Yes3 | Yes3 | Yes | Yes | Yes | +| **Int32** | Yes2 | Yes4 | Yes4 | — | Yes | Yes3,4 | Yes3,4 | Yes3 | Yes3 | Yes | Yes | Yes | +| **Int64** | Yes2 | Yes4 | Yes4 | Yes4 | — | Yes3,4 | Yes3,4 | Yes3,4 | Yes3 | Yes | Yes | Yes | +| **Uint8** | Yes2 | Yes4 | Yes | Yes | Yes | — | Yes | Yes | Yes | Yes | Yes | Yes | +| **Uint16** | Yes2 | Yes4 | Yes4 | Yes | Yes | Yes4 | — | Yes | Yes | Yes | Yes | Yes | +| **Uint32** | Yes2 | Yes4 | Yes4 | Yes4 | Yes | Yes4 | Yes4 | — | Yes | Yes | Yes | Yes | +| **Uint64** | Yes2 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | — | Yes | Yes | Yes | +| **Float** | Yes2 | Yes4 | Yes4 | Yes4 | Yes4 | Yes3,4 | Yes3,4 | Yes3,4 | Yes3,4 | — | Yes | No | +| **Double** | Yes2 | Yes4 | Yes4 | Yes4 | Yes4 | Yes3,4 | Yes3,4 | Yes3,4 | Yes3,4 | Yes | — | No | +| **Decimal** | No | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | — | +| **String** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Utf8** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Json** | No | No | No | No | No | No | No | No | No | No | No | No | +| **Yson** | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | Yes5 | No | +| **Uuid** | No | No | No | No | No | No | No | No | No | No | No | No | +| **Date** | No | Yes4 | Yes4 | Yes | Yes | Yes4 | Yes | Yes | Yes | Yes | Yes | No | +| **Datetime** | No | Yes4 | Yes4 | Yes4 | Yes | Yes4 | Yes4 | Yes | Yes | Yes | Yes | No | +| **Timestamp** | No | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes | Yes | Yes | No | +| **Interval** | No | Yes4 | Yes4 | Yes4 | Yes | Yes3,4 | Yes3,4 | Yes3,4 | Yes3 | Yes | Yes | No | +| **Date32** | No | Yes4 | Yes4 | Yes | Yes | Yes4 | Yes | Yes | Yes | Yes | Yes | No | +| **Datetime64** | No | Yes4 | Yes4 | Yes4 | Yes | Yes4 | Yes4 | Yes | Yes | Yes | Yes | No | +| **Timestamp64** | No | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes4 | Yes | Yes | Yes | No | +| **Interval64** | No | Yes4 | Yes4 | Yes4 | Yes | Yes3,4 | Yes3,4 | Yes3,4 | Yes3 | Yes | Yes | No | + +1 `True` is converted to `1`, `False` is converted to `0`. 2 Any value other than `0` is converted to `True`, `0` is converted to `False`. 3 Possible only in case of a non-negative value. -4 Possible only within the valid range. +4 Possible only in case of falling within the range of acceptable values. 5 Using the built-in function [Yson::ConvertTo](../udf/list/yson.md#ysonconvertto). -#### Converting to date and time data types - -| Type | Date | Datetime | Timestamp | Interval | -| --- | --- | --- | --- | --- | -| **Bool** | No | No | No | No | -| **INT** | Yes | Yes | Yes | Yes | -| **Uint** | Yes | Yes | Yes | Yes | -| **Float** | No | No | No | No | -| **Double** | No | No | No | No | -| **Decimal** | No | No | No | No | -| **String** | Yes | Yes | Yes | Yes | -| **Utf8** | Yes | Yes | Yes | Yes | -| **Json** | No | No | No | No | -| **Yson** | No | No | No | No | -| **Uuid** | No | No | No | No | -| **Date** | — | Yes | Yes | No | -| **Datetime** | Yes | — | Yes | No | -| **Timestamp** | Yes | Yes | — | No | -| **Interval** | No | No | No | — | - -#### Conversion to other data types - -| Type | String | Utf8 | Json | Yson | Uuid | -| --- | --- | --- | --- | --- | --- | -| **Bool** | Yes | No | No | No | No | -| **INT** | Yes | No | No | No | No | -| **Uint** | Yes | No | No | No | No | -| **Float** | Yes | No | No | No | No | -| **Double** | Yes | No | No | No | No | -| **Decimal** | Yes | No | No | No | No | -| **String** | — | Yes | Yes | Yes | Yes | -| **Utf8** | Yes | — | No | No | No | -| **Json** | Yes | Yes | — | No | No | -| **Yson** | Yes4 | No | No | No | No | -| **Uuid** | Yes | Yes | No | No | — | -| **Date** | Yes | Yes | No | No | No | -| **Datetime** | Yes | Yes | No | No | No | -| **Timestamp** | Yes | Yes | No | No | No | -| **Interval** | Yes | Yes | No | No | No | - -4 Using the built-in function [Yson::ConvertTo](../udf/list/yson.md#ysonconvertto). +#### Casting to date and time data types + +| Type | Date | Datetime | Timestamp | Interval | Date32 | Datetime64 | Timestamp64 | Interval64 | +| --------------- | ---- | -------- | --------- | -------- | ------ | ---------- | ----------- | ---------- | +| **Bool** | No | No | No | No | No | No | No | No | +| **Int8** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Int16** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Int32** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Int64** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Uint8** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Uint16** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Uint32** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Uint64** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Float** | No | No | No | No | No | No | No | No | +| **Double** | No | No | No | No | No | No | No | No | +| **Decimal** | No | No | No | No | No | No | No | No | +| **String** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Utf8** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | +| **Json** | No | No | No | No | No | No | No | No | +| **Yson** | No | No | No | No | No | No | No | No | +| **Uuid** | No | No | No | No | No | No | No | No | +| **Date** | — | Yes | Yes | No | Yes | Yes | Yes | No | +| **Datetime** | Yes | — | Yes | No | Yes | Yes | Yes | No | +| **Timestamp** | Yes | Yes | — | No | Yes | Yes | Yes | No | +| **Interval** | No | No | No | — | No | No | No | Yes | +| **Date32** | Yes | Yes | Yes | No | — | Yes | Yes | No | +| **Datetime64** | Yes | Yes | Yes | No | Yes | — | Yes | No | +| **Timestamp64** | Yes | Yes | Yes | No | Yes | Yes | — | No | +| **Interval64** | No | No | No | Yes | No | No | No | — | + +#### Casting to other data types + +| Type | String | Utf8 | Json | Yson | Uuid | +| --------------- | -------------- | ---- | ---- | ---- | ---- | +| **Bool** | Yes | No | No | No | No | +| **Int8** | Yes | No | No | No | No | +| **Int16** | Yes | No | No | No | No | +| **Int32** | Yes | No | No | No | No | +| **Int64** | Yes | No | No | No | No | +| **Uint8** | Yes | No | No | No | No | +| **Uint16** | Yes | No | No | No | No | +| **Uint32** | Yes | No | No | No | No | +| **Uint64** | Yes | No | No | No | No | +| **Float** | Yes | No | No | No | No | +| **Double** | Yes | No | No | No | No | +| **Decimal** | Yes | No | No | No | No | +| **String** | — | Yes | Yes | Yes | Yes | +| **Utf8** | Yes | — | No | No | No | +| **Json** | Yes | Yes | — | No | No | +| **Yson** | Yes1 | No | No | No | No | +| **Uuid** | Yes | Yes | No | No | — | +| **Date** | Yes | Yes | No | No | No | +| **Datetime** | Yes | Yes | No | No | No | +| **Timestamp** | Yes | Yes | No | No | No | +| **Interval** | Yes | Yes | No | No | No | +| **Date32** | Yes | Yes | No | No | No | +| **Datetime64** | Yes | Yes | No | No | No | +| **Timestamp64** | Yes | Yes | No | No | No | +| **Interval64** | Yes | Yes | No | No | No | + +1 Using the built-in function [Yson::ConvertTo](../udf/list/yson.md#ysonconvertto). ##### Examples @@ -177,26 +422,40 @@ Explicit casting using [CAST](../syntax/expressions.md#cast): ### Implicit casting {#implicit-cast} -Implicit type casting that occurs in basic operations ( +-\*/) between different data types. The table cells specify the operation result type, if the operation is possible: +Implicit type casting that occurs in basic operations (`+`, `-`, `*`, `/`, `%`) between different data types. The table cells specify the operation result type, if the operation is possible: #### Numeric types -| Type | Int | Uint | Float | Double | -| --- | --- | --- | --- | --- | -| **INT** | — | `INT` | `Float` | `Double` | -| **Uint** | `INT` | — | `Float` | `Double` | -| **Float** | `Float` | `Float` | — | `Double` | -| **Double** | `Double` | `Double` | `Double` | — | +When numeric types don't match, first BitCast of both arguments to the result type is performed, and then the operation. + +| Type | Int8 | Int16 | Int32 | Int64 | Uint8 | Uint16 | Uint32 | Uint64 | Float | Double | +| ---------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| **Int8** | — | `Int16` | `Int32` | `Int64` | `Int8` | `Uint16` | `Uint32` | `Uint64` | `Float` | `Double` | +| **Int16** | `Int16` | — | `Int32` | `Int64` | `Int16` | `Int16` | `Uint32` | `Uint64` | `Float` | `Double` | +| **Int32** | `Int32` | `Int32` | — | `Int64` | `Int32` | `Int32` | `Int32` | `Uint64` | `Float` | `Double` | +| **Int64** | `Int64` | `Int64` | `Int64` | — | `Int64` | `Int64` | `Int64` | `Int64` | `Float` | `Double` | +| **Uint8** | `Int8` | `Int16` | `Int32` | `Int64` | — | `Uint16` | `Uint32` | `Uint64` | `Float` | `Double` | +| **Uint16** | `Uint16` | `Int16` | `Int32` | `Int64` | `Uint16` | — | `Uint32` | `Uint64` | `Float` | `Double` | +| **Uint32** | `Uint32` | `Uint32` | `Int32` | `Int64` | `Uint32` | `Uint32` | — | `Uint64` | `Float` | `Double` | +| **Uint64** | `Uint64` | `Uint64` | `Uint64` | `Int64` | `Uint64` | `Uint64` | `Uint64` | — | `Float` | `Double` | +| **Float** | `Float` | `Float` | `Float` | `Float` | `Float` | `Float` | `Float` | `Float` | — | `Double` | +| **Double** | `Double` | `Double` | `Double` | `Double` | `Double` | `Double` | `Double` | `Double` | `Double` | — | #### Date and time types -| Type | Date | Datetime | Timestamp | Interval | TzDate | TzDatetime | TzTimestamp | -| --- | --- | --- | --- | --- | --- | --- | --- | -| **Date** | — | — | — | `Date` | — | — | — | -| **Datetime** | — | — | — | `Datetime` | — | — | — | -| **Timestamp** | — | — | — | `Timestamp` | — | — | — | -| **Interval** | `Date` | `Datetime` | `Timestamp` | — | `TzDate` | `TzDatetime` | `TzTimestamp` | -| **TzDate** | — | — | — | `TzDate` | — | — | — | -| **TzDatetime** | — | — | — | `TzDatetime` | — | — | — | -| **TzTimestamp** | — | — | — | `TzTimestamp` | — | — | — | - +| Type | Date | Datetime | Timestamp | Interval | TzDate | TzDatetime | TzTimestamp | Date32 | Datetime64 | Timestamp64 | Interval64 | TzDate32 | TzDatetime64 | TzTimestamp64 | +| ----------------- | ---- | ---------- | ----------- | -------- | -------- | ------------ | ------------- | -------- | ------------ | ------------- | ---------- | ---------- | -------------- | --------------- | +| **Date** | — | `DateTime` | `Timestamp` | — | `TzDate` | `TzDatetime` | `TzTimestamp` | `Date32` | `DateTime64` | `Timestamp64` | — | `TzDate32` | `TzDatetime64` | `TzTimestamp64` | +| **Datetime** | — | — | `Timestamp` | — | — | `TzDatetime` | `TzTimestamp` | — | `Datetime64` | `Timestamp64` | — | — | `TzDatetime64` | `TzTimestamp64` | +| **Timestamp** | — | — | — | — | — | — | `TzTimestamp` | — | — | `Timestamp64` | — | — | — | `TzTimestamp64` | +| **Interval** | — | — | — | — | — | — | — | — | — | — | — | — | — | — | +| **TzDate** | — | — | — | — | — | `TzDatetime` | `TzTimestamp` | — | — | — | — | `TzDate32` | `TzDatetime64` | `TzTimestamp64` | +| **TzDatetime** | — | — | — | — | — | — | `TzTimestamp` | — | — | — | — | — | `TzDatetime64` | `TzTimestamp64` | +| **TzTimestamp** | — | — | — | — | — | — | — | — | — | — | — | — | — | `TzTimestamp64` | +| **Date32** | — | — | — | — | — | — | — | — | `DateTime64` | `Timestamp64` | — | `TzDate32` | `TzDatetime64` | `TzTimestamp64` | +| **Datetime64** | — | — | — | — | — | — | — | — | — | `Timestamp64` | — | — | `TzDatetime64` | `TzTimestamp64` | +| **Timestamp64** | — | — | — | — | — | — | — | — | — | — | — | — | — | `TzTimestamp64` | +| **Interval64** | — | — | — | — | — | — | — | — | — | — | — | — | — | — | +| **TzDate32** | — | — | — | — | — | — | — | — | — | — | — | — | `TzDatetime64` | `TzTimestamp64` | +| **TzDatetime64** | — | — | — | — | — | — | — | — | — | — | — | — | — | `TzTimestamp64` | +| **TzTimestamp64** | — | — | — | — | — | — | — | — | — | — | — | — | — | — | \ No newline at end of file diff --git a/ydb/docs/en/core/yql/reference/udf/list/datetime.md b/ydb/docs/en/core/yql/reference/udf/list/datetime.md index 7ef3b99842d6..bfe2e1ac8f89 100644 --- a/ydb/docs/en/core/yql/reference/udf/list/datetime.md +++ b/ydb/docs/en/core/yql/reference/udf/list/datetime.md @@ -1,49 +1,68 @@ # DateTime -In the DateTime module, the main internal representation format is `Resource`, which stores the following date components: - -* Year (12 bits). -* Month (4 bits). -* Day (5 bits). -* Hour (5 bits). -* Minute (6 bits). -* Second (6 bits). -* Microsecond (20 bits). -* TimezoneId (16 bits). -* DayOfYear (9 bits): Day since the beginning of the year. -* WeekOfYear (6 bits): Week since the beginning of the year, January 1 is always in week 1. -* WeekOfYearIso8601 (6 bits): Week of the year according to ISO 8601 (the first week is the one that includes January 4). +The DateTime module provides a set of functions for working with dates and times in {{ ydb-short-name }}. These functions support all available timestamp and interval data types with both [basic range of valid values](../../types/primitive.md#datetime-basic) and [extended range](../../types/primitive.md#datetime-extended). Additionally, these functions use their own internal representation of values, where each value is split into separate components. This representation is described [below](#resource). + +The simplest operations with timestamps and intervals can be performed without using the DateTime module. For example, conversion between strings and timestamps according to [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) is available through [`CAST`](../../syntax/expressions.md#cast), timestamp precision can also be changed using `CAST`, and [arithmetic operators](../../syntax/expressions.md#math-operators) work between timestamps and intervals. The DateTime module is intended for tasks where these basic operations are insufficient and more complex transformations are required. + +## Internal representation format {#resource} + +Most functions in the DateTime module operate not on original timestamps and intervals, but on an internal representation based on a special [resource](../../types/special.md) data type. This represents a pointer to a data structure in memory where time components are stored separately. Working with resources happens exclusively through DateTime module functions. The typical workflow with this module (see examples [at the end of the article](#standard-scenarios)) is as follows: + +1. Call the [`Split`](#split) function to get the internal representation from the original timestamp, or [`Parse...`](#parse) to get it from a string. +2. If necessary, call functions that modify this internal representation as needed, for example [`Shift...`](#shift), [`StartOf...`](#startof) or [`Update...`](#update). +3. Call one of the functions to create a new value based on the internal representation, which can then be saved to tables or returned from a query: + + - [`Make...`](#make) to create a new timestamp from the internal representation (not necessarily with the same precision as the original); + - [`Format`](#format) to get a string representation; + - [`Get...`](#get) to get individual components. + +{{ ydb-short-name }} supports two ranges of valid timestamp values: [basic](../../types/primitive.md#datetime-basic) and [extended](../../types/primitive.md#datetime-extended). In the DateTime module, these correspond to two separate internal representations: `Resource` for basic data types and `Resource` for data types with extended range of valid values. + +`Resource` and `Resource` contain the following date components: + +* Year (for `Resource` 12 bits, unsigned; for `Resource` 19 bits, signed); +* Month (4 bits); +* Day (5 bits); +* Hour (5 bits); +* Minute (6 bits); +* Second (6 bits); +* Microsecond (20 bits); +* TimezoneId (16 bits); +* DayOfYear (9 bits): Day since the beginning of the year; +* WeekOfYear (6 bits): Week since the beginning of the year, January 1 is always in week 1; +* WeekOfYearIso8601 (6 bits): Week of the year according to ISO 8601 (the first week is the one that includes January 4); * DayOfWeek (3 bits): Day of the week. If the timezone is not GMT, the components store the local time for the relevant timezone. ## Split {#split} -Conversion from a primitive type to an internal representation. It's always successful on a non-empty input. +Conversion from a {{ ydb-short-name }} primitive type to the [internal representation](#resource) of the DateTime module. Conversion is always successful when the required value is provided as input to the function. ### List of functions -* `DateTime::Split(Date{Flags:AutoMap}) -> Resource` -* `DateTime::Split(Datetime{Flags:AutoMap}) -> Resource` -* `DateTime::Split(Timestamp{Flags:AutoMap}) -> Resource` -* `DateTime::Split(TzDate{Flags:AutoMap}) -> Resource` -* `DateTime::Split(TzDatetime{Flags:AutoMap}) -> Resource` -* `DateTime::Split(TzTimestamp{Flags:AutoMap}) -> Resource` +* `DateTime::Split(Date/TzDate/Datetime/TzDatetime/Timestamp/TzTimestamp{Flags:AutoMap}) -> Resource`; +* `DateTime::Split(Date32/TzDate32/Datetime64/TzDatetime64/Timestamp64/TzTimestamp64{Flags:AutoMap}) -> Resource`. -Functions that accept `Resource` as input, can be called directly from the primitive date/time type. An implicit conversion will be made in this case by calling a relevant `Split` function. +Functions that accept `Resource` or `Resource` as input can be called directly from the primitive date/time type. In this case, an implicit conversion will be made by calling the corresponding `Split` function. ## Make... {#make} -Making a primitive type from an internal representation. It's always successful on a non-empty input. +Creating a {{ ydb-short-name }} primitive type from the [internal representation](#resource) of the DateTime module. Conversion is always successful when the required value is provided as input to the function. ### List of functions * `DateTime::MakeDate(Resource{Flags:AutoMap}) -> Date` -* `DateTime::MakeDatetime(Resource{Flags:AutoMap}) -> Datetime` -* `DateTime::MakeTimestamp(Resource{Flags:AutoMap}) -> Timestamp` -* `DateTime::MakeTzDate(Resource{Flags:AutoMap}) -> TzDate` -* `DateTime::MakeTzDatetime(Resource{Flags:AutoMap}) -> TzDatetime` -* `DateTime::MakeTzTimestamp(Resource{Flags:AutoMap}) -> TzTimestamp` +* `DateTime::MakeDate32(Resource{Flags:AutoMap}) -> Date32`; +* `DateTime::MakeTzDate32(Resource{Flags:AutoMap}) -> TzDate32`; +* `DateTime::MakeDatetime(Resource{Flags:AutoMap}) -> Datetime`; +* `DateTime::MakeTzDatetime(Resource{Flags:AutoMap}) -> TzDatetime`; +* `DateTime::MakeDatetime64(Resource{Flags:AutoMap}) -> Datetime64`; +* `DateTime::MakeTzDatetime64(Resource{Flags:AutoMap}) -> TzDatetime64`; +* `DateTime::MakeTimestamp(Resource{Flags:AutoMap}) -> Timestamp`; +* `DateTime::MakeTzTimestamp(Resource{Flags:AutoMap}) -> TzTimestamp`; +* `DateTime::MakeTimestamp64(Resource{Flags:AutoMap}) -> Timestamp64`; +* `DateTime::MakeTzTimestamp64(Resource{Flags:AutoMap}) -> TzTimestamp64`. ### Examples @@ -56,31 +75,32 @@ SELECT DateTime::MakeTimestamp(DateTime::Split(TzDatetime("2019-01-01T00:00:00,Europe/Moscow"))), -- 2018-12-31T21:00:00Z (conversion to UTC) DateTime::MakeDate(TzDatetime("2019-01-01T12:00:00,GMT")) - -- 2019-01-01 (Datetime -> Date with implicit Split)> + -- 2019-01-01 (Datetime -> Date with implicit Split) ``` ## Get... {#get} -Extracting a component from an internal representation. +Extracting a component from the [internal representation](#resource). ### List of functions -* `DateTime::GetYear(Resource{Flags:AutoMap}) -> Uint16` -* `DateTime::GetDayOfYear(Resource{Flags:AutoMap}) -> Uint16` -* `DateTime::GetMonth(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetMonthName(Resource{Flags:AutoMap}) -> String` -* `DateTime::GetWeekOfYear(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetWeekOfYearIso8601(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetDayOfMonth(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetDayOfWeek(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetDayOfWeekName(Resource{Flags:AutoMap}) -> String` -* `DateTime::GetHour(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetMinute(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetSecond(Resource{Flags:AutoMap}) -> Uint8` -* `DateTime::GetMillisecondOfSecond(Resource{Flags:AutoMap}) -> Uint32` -* `DateTime::GetMicrosecondOfSecond(Resource{Flags:AutoMap}) -> Uint32` -* `DateTime::GetTimezoneId(Resource{Flags:AutoMap}) -> Uint16` -* `DateTime::GetTimezoneName(Resource{Flags:AutoMap}) -> String` +* `DateTime::GetYear(Resource{Flags:AutoMap}) -> Uint16`; +* `DateTime::GetYear(Resource{Flags:AutoMap}) -> Int32`; +* `DateTime::GetDayOfYear(Resource/Resource{Flags:AutoMap}) -> Uint16`; +* `DateTime::GetMonth(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetMonthName(Resource/Resource{Flags:AutoMap}) -> String`; +* `DateTime::GetWeekOfYear(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetWeekOfYearIso8601(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetDayOfMonth(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetDayOfWeek(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetDayOfWeekName(Resource/Resource{Flags:AutoMap}) -> String`; +* `DateTime::GetHour(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetMinute(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetSecond(Resource/Resource{Flags:AutoMap}) -> Uint8`; +* `DateTime::GetMillisecondOfSecond(Resource/Resource{Flags:AutoMap}) -> Uint32`; +* `DateTime::GetMicrosecondOfSecond(Resource/Resource{Flags:AutoMap}) -> Uint32`; +* `DateTime::GetTimezoneId(Resource/Resource{Flags:AutoMap}) -> Uint16`; +* `DateTime::GetTimezoneName(Resource/Resource{Flags:AutoMap}) -> String`. ### Examples @@ -97,12 +117,13 @@ SELECT ## Update {#update} -Updating one or more components in the internal representation. Returns either an updated copy or NULL, if an update produces an invalid date or other inconsistencies. +Updating one or more components in the [internal representation](#resource). Returns either an updated copy or `NULL`, if an update produces an invalid date or other inconsistencies. ### List of functions ```yql -DateTime::Update( Resource{Flags:AutoMap}, [ Year:Uint16?, Month:Uint8?, Day:Uint8?, Hour:Uint8?, Minute:Uint8?, Second:Uint8?, Microsecond:Uint32?, Timezone:String? ]) -> Resource? +DateTime::Update(Resource{Flags:AutoMap}, [ Year:Uint16?, Month:Uint8?, Day:Uint8?, Hour:Uint8?, Minute:Uint8?, Second:Uint8?, Microsecond:Uint32?, Timezone:String? ]) -> Resource? +DateTime::Update(Resource{Flags:AutoMap}, [ Year:Int32?, Month:Uint8?, Day:Uint8?, Hour:Uint8?, Minute:Uint8?, Second:Uint8?, Microsecond:Uint32?, Timezone:String? ]) -> Resource? ``` ### Examples @@ -127,9 +148,12 @@ Getting a Timestamp from the number of seconds/milliseconds/microseconds since t ### List of functions -* `DateTime::FromSeconds(Uint32{Flags:AutoMap}) -> Timestamp` -* `DateTime::FromMilliseconds(Uint64{Flags:AutoMap}) -> Timestamp` -* `DateTime::FromMicroseconds(Uint64{Flags:AutoMap}) -> Timestamp` +* `DateTime::FromSeconds(Uint32{Flags:AutoMap}) -> Timestamp`; +* `DateTime::FromSeconds64(Int64{Flags:AutoMap}) -> Timestamp64`; +* `DateTime::FromMilliseconds(Uint64{Flags:AutoMap}) -> Timestamp`; +* `DateTime::FromMilliseconds64(Int64{Flags:AutoMap}) -> Timestamp64`; +* `DateTime::FromMicroseconds(Uint64{Flags:AutoMap}) -> Timestamp`; +* `DateTime::FromMicroseconds64(Int64{Flags:AutoMap}) -> Timestamp64`. ## To... {#to} @@ -137,9 +161,12 @@ Getting a number of seconds/milliseconds/microseconds since the UTC Epoch from a ### List of functions -* `DateTime::ToSeconds(Date/DateTime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint32` -* `DateTime::ToMilliseconds(Date/DateTime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64` -* `DateTime::ToMicroseconds(Date/DateTime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64` +* `DateTime::ToSeconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint32`; +* `DateTime::ToSeconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64`; +* `DateTime::ToMilliseconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64`; +* `DateTime::ToMilliseconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64`; +* `DateTime::ToMicroseconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64`; +* `DateTime::ToMicroseconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64`. ### Examples @@ -155,22 +182,40 @@ Conversions between `Interval` and various time units. ### List of functions -* `DateTime::ToDays(Interval{Flags:AutoMap}) -> Int16` -* `DateTime::ToHours(Interval{Flags:AutoMap}) -> Int32` -* `DateTime::ToMinutes(Interval{Flags:AutoMap}) -> Int32` -* `DateTime::ToSeconds(Interval{Flags:AutoMap}) -> Int32` -* `DateTime::ToMilliseconds(Interval{Flags:AutoMap}) -> Int64` -* `DateTime::ToMicroseconds(Interval{Flags:AutoMap}) -> Int64` -* `DateTime::IntervalFromDays(Int16{Flags:AutoMap}) -> Interval` -* `DateTime::IntervalFromHours(Int32{Flags:AutoMap}) -> Interval` -* `DateTime::IntervalFromMinutes(Int32{Flags:AutoMap}) -> Interval` -* `DateTime::IntervalFromSeconds(Int32{Flags:AutoMap}) -> Interval` -* `DateTime::IntervalFromMilliseconds(Int64{Flags:AutoMap}) -> Interval` -* `DateTime::IntervalFromMicroseconds(Int64{Flags:AutoMap}) -> Interval` - -AddTimezone doesn't affect the output of ToSeconds() in any way, because ToSeconds() always returns GMT time. - -You can also create an Interval from a string literal in the format [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601%23Durations). Time units up to a week are supported, inclusive. +* `DateTime::ToDays(Interval{Flags:AutoMap}) -> Int32`; +* `DateTime::ToDays(Interval64{Flags:AutoMap}) -> Int32`; +* `DateTime::ToHours(Interval{Flags:AutoMap}) -> Int32`; +* `DateTime::ToHours(Interval64{Flags:AutoMap}) -> Int64`; +* `DateTime::ToMinutes(Interval{Flags:AutoMap}) -> Int32`; +* `DateTime::ToMinutes(Interval64{Flags:AutoMap}) -> Int64`; +* `DateTime::ToSeconds(Interval{Flags:AutoMap}) -> Int64`; +* `DateTime::ToSeconds(Interval64{Flags:AutoMap}) -> Int64`; +* `DateTime::ToMilliseconds(Interval{Flags:AutoMap}) -> Int64`; +* `DateTime::ToMilliseconds(Interval64{Flags:AutoMap}) -> Int64`; +* `DateTime::ToMicroseconds(Interval{Flags:AutoMap}) -> Int64`; +* `DateTime::ToMicroseconds(Interval64{Flags:AutoMap}) -> Int64`; +* `DateTime::IntervalFromDays(Int32{Flags:AutoMap}) -> Interval`; +* `DateTime::Interval64FromDays(Int32{Flags:AutoMap}) -> Interval64`; +* `DateTime::IntervalFromHours(Int32{Flags:AutoMap}) -> Interval`; +* `DateTime::Interval64FromHours(Int64{Flags:AutoMap}) -> Interval64`; +* `DateTime::IntervalFromMinutes(Int32{Flags:AutoMap}) -> Interval`; +* `DateTime::Interval64FromMinutes(Int64{Flags:AutoMap}) -> Interval64`; +* `DateTime::IntervalFromSeconds(Int64{Flags:AutoMap}) -> Interval`; +* `DateTime::Interval64FromSeconds(Int64{Flags:AutoMap}) -> Interval64`; +* `DateTime::IntervalFromMilliseconds(Int64{Flags:AutoMap}) -> Interval`; +* `DateTime::Interval64FromMilliseconds(Int64{Flags:AutoMap}) -> Interval64`; +* `DateTime::IntervalFromMicroseconds(Int64{Flags:AutoMap}) -> Interval`; +* `DateTime::Interval64FromMicroseconds(Int64{Flags:AutoMap}) -> Interval64`. + +`AddTimezone` doesn't affect the output of `ToSeconds()` in any way, because `ToSeconds()` always returns GMT time. + +Interval can also be created from a string literal in the format [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601%23Durations). + +{% note warning %} + +Currently, only literals for deterministic intervals are supported. All dimensions larger than a week — `M` (month) and `Y` (year) — are not fixed, since their duration is determined only by external context, the calendar. + +{% endnote %} ### Examples @@ -178,7 +223,7 @@ You can also create an Interval from a string literal in the format [ISO 8601](h SELECT DateTime::ToDays(Interval("PT3000M")), -- 2 DateTime::IntervalFromSeconds(1000000), -- 11 days 13 hours 46 minutes 40 seconds - DateTime::ToDays(cast('2018-01-01' as date) - cast('2017-12-31' as date)); --1 + DateTime::ToDays(CAST('2018-01-01' as date) - CAST('2017-12-31' as date)); --1 ``` ## StartOf... / EndOf... / TimeOfDay {#startof} @@ -187,18 +232,30 @@ Get the start (end) of the period including the date/time. If the result is inva ### List of functions -* `DateTime::StartOfYear(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::EndOfYear(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::StartOfQuarter(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::EndOfQuarter(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::StartOfMonth(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::EndOfMonth(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::StartOfWeek(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::EndOfWeek(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::StartOfDay(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::EndOfDay(Resource{Flags:AutoMap}) -> Resource?` -* `DateTime::StartOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?` -* `DateTime::EndOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfYear(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfYear(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfYear(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfYear(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfMonth(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfMonth(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfMonth(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfMonth(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfWeek(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfWeek(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfWeek(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfWeek(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfDay(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOfDay(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfDay(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOfDay(Resource{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?`; +* `DateTime::StartOf(Resource{Flags:AutoMap}, Interval64{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?`; +* `DateTime::EndOf(Resource{Flags:AutoMap}, Interval64{Flags:AutoMap}) -> Resource?`. The `StartOf`/`EndOf` functions are intended for grouping by an arbitrary period within a day. The result differs from the input value only by time components. A period exceeding one day is treated as a day (an equivalent of `StartOfDay`/`EndOfDay`). If a day doesn't include an integer number of periods, the number is rounded to the nearest time from the beginning of the day that is a multiple of the specified period. When the interval is zero, the output is same as the input. A negative interval is treated as a positive one. @@ -206,7 +263,8 @@ The `EndOf...` functions are intended for obtaining the latest moment in the sam The functions treat periods longer than one day in a different manner than the same-name functions in the old library. The time components are always reset to zero (this makes sense, because these functions are mainly used for grouping by the period). You can also specify a time period within a day: -* `DateTime::TimeOfDay(Resource{Flags:AutoMap}) -> Interval` +* `DateTime::TimeOfDay(Resource{Flags:AutoMap}) -> Interval`; +* `DateTime::TimeOfDay(Resource{Flags:AutoMap}) -> Interval64`. ### Examples @@ -243,9 +301,12 @@ Returns either an updated copy or NULL, if an update produces an invalid date or ### List of functions -* `DateTime::ShiftYears(Resource{Flags:AutoMap}, Int32) -> Resource?` -* `DateTime::ShiftQuarters(Resource{Flags:AutoMap}, Int32) -> Resource?` -* `DateTime::ShiftMonths(Resource{Flags:AutoMap}, Int32) -> Resource?` +* `DateTime::ShiftYears(Resource{Flags:AutoMap}, Int32) -> Resource?`; +* `DateTime::ShiftYears(Resource{Flags:AutoMap}, Int32) -> Resource?`; +* `DateTime::ShiftQuarters(Resource{Flags:AutoMap}, Int32) -> Resource?`; +* `DateTime::ShiftQuarters(Resource{Flags:AutoMap}, Int32) -> Resource?`; +* `DateTime::ShiftMonths(Resource{Flags:AutoMap}, Int32) -> Resource?`; +* `DateTime::ShiftMonths(Resource{Flags:AutoMap}, Int32) -> Resource?`. If the resulting number of the day in the month exceeds the maximum allowed, then the `Day` field will accept the last day of the month without changing the time (see examples). @@ -270,20 +331,20 @@ Get a string representation of a time using an arbitrary formatting string. ### List of functions -* `DateTime::Format(String, alwaysWriteFractionalSeconds:Bool?) -> (Resource{Flags:AutoMap}) -> String` +* `DateTime::Format(String, alwaysWriteFractionalSeconds:Bool?) -> (Resource{Flags:AutoMap}) -> String` A set of specifiers is implemented for the formatting string: -* `%%`: % character. -* `%Y`: 4-digit year. -* `%m`: 2-digit month. -* `%d`: 2-digit day. -* `%H`: 2-digit hour. -* `%M`: 2-digit minutes. -* `%S`: 2-digit seconds -- or xx.xxxxxx in the case of non-empty microseconds (only if `alwaysWriteFractionalSeconds` is not set to `True`). -* `%z`: +hhmm or -hhmm. -* `%Z`: IANA name of the timezone. -* `%b`: A short three-letter English name of the month (Jan). +* `%%`: % character; +* `%Y`: year, 1–6 digits and sign for BC dates; +* `%m`: 2-digit month; +* `%d`: 2-digit day; +* `%H`: 2-digit hour; +* `%M`: 2-digit minutes; +* `%S`: 2-digit seconds or `XX.XXXXXX` in the case of non-empty microseconds (only if `alwaysWriteFractionalSeconds` is not set to `True`); +* `%z`: `+hhmm` or `-hhmm`; +* `%Z`: IANA name of the timezone; +* `%b`: A short three-letter English name of the month (Jan); * `%B`: A full English name of the month (January). All other characters in the format string are passed on without changes. @@ -298,25 +359,26 @@ SELECT -- "2019-01-01 01:02:03 Europe/Moscow" ``` -## Parse {#parse} +## Parse/Parse64 {#parse} Parse a string into an internal representation using an arbitrary formatting string. Default values are used for empty fields. If errors are raised, NULL is returned. ### List of functions -* `DateTime::Parse(String) -> (String{Flags:AutoMap}) -> Resource?` +* `DateTime::Parse(String) -> (String{Flags:AutoMap}) -> Resource?`; +* `DateTime::Parse64(String) -> (String{Flags:AutoMap}) -> Resource?`. Implemented specifiers: -* `%%`: the % character. -* `%Y`: 4-digit year (1970). -* `%m`: 2-digit month (1). -* `%d`: 2-digit day (1). -* `%H`: 2-digit hour (0). -* `%M`: 2-digit minutes (0). -* `%S`: Seconds (0), can also accept microseconds in the formats from xx. up to xx.xxxxxx -* `%Z`: The IANA name of the timezone (GMT). -* `%b`: A short three-letter case-insensitive English name of the month (Jan). +* `%%`: the % character; +* `%Y`: 4-digit year when using `Parse`, or 1–6 digits and sign for BC dates when using `Parse64`; +* `%m`: 2-digit month; +* `%d`: 2-digit day; +* `%H`: 2-digit hour; +* `%M`: 2-digit minutes; +* `%S`: Seconds, can also accept microseconds in the formats from `XX` up to `XX.XXXXXX`; +* `%Z`: The IANA name of the timezone (e.g., GMT); +* `%b`: A short three-letter case-insensitive English name of the month (e.g., Jan); * `%B`: A full case-insensitive English name of the month (January). ### Examples @@ -326,24 +388,26 @@ $parse1 = DateTime::Parse("%H:%M:%S"); $parse2 = DateTime::Parse("%S"); $parse3 = DateTime::Parse("%m/%d/%Y"); $parse4 = DateTime::Parse("%Z"); +$parse5 = DateTime::Parse64("%m/%d/%Y"); SELECT DateTime::MakeDatetime($parse1("01:02:03")), -- 1970-01-01T01:02:03Z DateTime::MakeTimestamp($parse2("12.3456")), -- 1970-01-01T00:00:12.345600Z DateTime::MakeTimestamp($parse3("02/30/2000")), -- NULL (Feb 30) - DateTime::MakeTimestamp($parse4("Canada/Central")); -- 1970-01-01T06:00:00Z (conversion to UTC) + DateTime::MakeTimestamp($parse4("Canada/Central")), -- 1970-01-01T06:00:00Z (conversion to UTC) + DateTime::MakeTimestamp64($parse5("02/10/1931")); -- 1931-02-10T00:00:00Z (conversion to UTC) ``` -For the common formats, wrappers around the corresponding util methods are supported. You can only get TM with components in the UTC timezone. - ## Parse specific formats +For the common formats, wrappers around the corresponding util methods are supported. You can only get TM with components in the UTC timezone. + ### List of functions -* `DateTime::ParseRfc822(String{Flags:AutoMap}) -> Resource?` -* `DateTime::ParseIso8601(String{Flags:AutoMap}) -> Resource?` -* `DateTime::ParseHttp(String{Flags:AutoMap}) -> Resource?` -* `DateTime::ParseX509(String{Flags:AutoMap}) -> Resource?` +* `DateTime::ParseRfc822(String{Flags:AutoMap}) -> Resource?`; +* `DateTime::ParseIso8601(String{Flags:AutoMap}) -> Resource?`; +* `DateTime::ParseHttp(String{Flags:AutoMap}) -> Resource?`; +* `DateTime::ParseX509(String{Flags:AutoMap}) -> Resource?`. ### Examples @@ -359,7 +423,7 @@ SELECT -- 2009-10-14T16:55:33Z ``` -## Standard scenarios +## Standard scenarios {#standard-scenarios} ### Conversions between strings and seconds @@ -370,15 +434,14 @@ $datetime_parse = DateTime::Parse("%Y-%m-%d %H:%M:%S"); $datetime_parse_tz = DateTime::Parse("%Y-%m-%d %H:%M:%S %Z"); SELECT - DateTime::ToSeconds(TzDateTime("2019-09-16T00:00:00,Europe/Moscow")) AS md_us1, -- 1568581200 - DateTime::ToSeconds(DateTime::MakeDatetime($datetime_parse_tz("2019-09-16 00:00:00" || " Europe/Moscow"))), -- 1568581200 - DateTime::ToSeconds(DateTime::MakeDatetime(DateTime::Update($datetime_parse("2019-09-16 00:00:00"), "Europe/Moscow" as Timezone))), -- 1568581200 - + DateTime::ToSeconds(TzDatetime("2019-09-16T00:00:00,Europe/Moscow")) AS md_us1, -- 1568581200 + DateTime::ToSeconds(DateTime::MakeDatetime($datetime_parse_tz("2019-09-16 00:00:00" || " Europe/Moscow"))), -- 1568581200 + DateTime::ToSeconds(DateTime::MakeDatetime(DateTime::Update($datetime_parse("2019-09-16 00:00:00"), "Europe/Moscow" AS Timezone))), -- 1568581200 -- INCORRECT (Date imports time as GMT, but AddTimezone has no effect on ToSeconds that always returns GMT time) DateTime::ToSeconds(AddTimezone(Date("2019-09-16"), 'Europe/Moscow')) AS md_us2, -- 1568592000 ``` -Converting a string date (in the Moscow timezone) to seconds (in the Moscow timezone). DateTime::ToSeconds() exports only to GMT. That's why we should put timezones aside for a while and use only GMT (as if we assumed for a while that Moscow is in GMT): +Converting a string date (in the Moscow timezone) to seconds (in the Moscow timezone). Since `DateTime::ToSeconds()` exports only GMT, we have to temporarily forget about timezones and work only in GMT (it looks like we temporarily assume that Moscow is in GMT timezone): ```yql $date_parse = DateTime::Parse("%Y-%m-%d"); @@ -405,7 +468,7 @@ SELECT $date_format(AddTimezone(DateTime::FromSeconds(1568592000), 'Europe/Moscow')) -- "2019-09-16 03:00:00 Europe/Moscow" ``` -Converting seconds (in the Moscow timezone) to a string date (in the Moscow timezone). In this case, the %Z timezone is output for reference: usually, it's not needed because it's "GMT" and might mislead you. +Converting seconds (in the Moscow timezone) to a string date (in the Moscow timezone). In this case, the `%Z` timezone is output for reference: usually, it's not needed because it's "GMT" and might mislead you. ```yql $date_format = DateTime::Format("%Y-%m-%d %H:%M:%S %Z"); @@ -446,7 +509,7 @@ This way, you can convert only constants: ```yql SELECT - TzDateTime("2019-09-16T00:00:00,Europe/Moscow"), -- 2019-09-16T00:00:00,Europe/Moscow + TzDatetime("2019-09-16T00:00:00,Europe/Moscow"), -- 2019-09-16T00:00:00,Europe/Moscow Date("2019-09-16") -- 2019-09-16 ``` @@ -454,21 +517,21 @@ But this way, you can convert a constant, a named expression, or a table field: ```yql SELECT - CAST("2019-09-16T00:00:00,Europe/Moscow" AS TzDateTime), -- 2019-09-16T00:00:00,Europe/Moscow +CAST("2019-09-16T00:00:00,Europe/Moscow" AS TzDatetime), -- 2019-09-16T00:00:00,Europe/Moscow CAST("2019-09-16" AS Date) -- 2019-09-16 ``` ### Converting time to date -A CAST to Date or TzDate outputs a GMT date for a midnight, local time (for example, for Moscow time 2019-10-22 00:00:00, the date 2019-10-21 is returned). To get a date in the local timezone, you can use DateTime::Format. +A `CAST` to `Date` or `TzDate` outputs a GMT date for a midnight, local time (for example, for Moscow time 2019-10-22 00:00:00, the date 2019-10-21 is returned). To get a date in the local timezone, you can use DateTime::Format. ```yql -$x = DateTime("2019-10-21T21:00:00Z"); +$x = Datetime("2019-10-21T21:00:00Z"); SELECT AddTimezone($x, "Europe/Moscow"), -- 2019-10-22T00:00:00,Europe/Moscow - cast($x as TzDate), -- 2019-10-21,GMT - cast(AddTimezone($x, "Europe/Moscow") as TzDate), -- 2019-10-21,Europe/Moscow - cast(AddTimezone($x, "Europe/Moscow") as Date), -- 2019-10-21 + CAST($x as TzDate), -- 2019-10-21,GMT + CAST(AddTimezone($x, "Europe/Moscow") as TzDate), -- 2019-10-21,Europe/Moscow + CAST(AddTimezone($x, "Europe/Moscow") as Date), -- 2019-10-21 DateTime::Format("%Y-%m-%d %Z")(AddTimezone($x, "Europe/Moscow")), -- 2019-10-22 Europe/Moscow ``` @@ -479,9 +542,9 @@ SELECT CAST(TzDatetime("1970-01-01T23:59:59,Europe/Moscow") as TzDate); /* Fatal: Timestamp 1970-01-01T23:59:59.000000,Europe/Moscow cannot be casted to TzDate */ ``` -Starting from the Unix epoch, there is no valid value representing midnight on 01/01/1970 for the Europe/Moscow timezone. As a result, such a cast is impossible and fails at runtime. +There is no valid value, starting from the Unix epoch, that can represent midnight on 01/01/1970 for the Moscow timezone. As a result, such a cast is considered impossible and generates a runtime error. -At the same time, values with a negative timezone offset are converted correctly: +At the same time, values with a negative timezone offset return a correct result: ```yql SELECT CAST(TzDatetime("1970-01-01T23:59:59,America/Los_Angeles") as TzDate); From 4bd641437e720de67e07af4f51735e0d412fe13f Mon Sep 17 00:00:00 2001 From: Anton Bobkov Date: Mon, 22 Sep 2025 16:18:33 +0300 Subject: [PATCH 2/4] Edits --- .../core/yql/reference/udf/list/datetime.md | 282 +++++++++--------- 1 file changed, 141 insertions(+), 141 deletions(-) diff --git a/ydb/docs/en/core/yql/reference/udf/list/datetime.md b/ydb/docs/en/core/yql/reference/udf/list/datetime.md index bfe2e1ac8f89..887317d9eca4 100644 --- a/ydb/docs/en/core/yql/reference/udf/list/datetime.md +++ b/ydb/docs/en/core/yql/reference/udf/list/datetime.md @@ -12,26 +12,26 @@ Most functions in the DateTime module operate not on original timestamps and int 2. If necessary, call functions that modify this internal representation as needed, for example [`Shift...`](#shift), [`StartOf...`](#startof) or [`Update...`](#update). 3. Call one of the functions to create a new value based on the internal representation, which can then be saved to tables or returned from a query: - - [`Make...`](#make) to create a new timestamp from the internal representation (not necessarily with the same precision as the original); - - [`Format`](#format) to get a string representation; - - [`Get...`](#get) to get individual components. + - [`Make...`](#make) to create a new timestamp from the internal representation (not necessarily with the same precision as the original) + - [`Format`](#format) to get a string representation + - [`Get...`](#get) to get individual components {{ ydb-short-name }} supports two ranges of valid timestamp values: [basic](../../types/primitive.md#datetime-basic) and [extended](../../types/primitive.md#datetime-extended). In the DateTime module, these correspond to two separate internal representations: `Resource` for basic data types and `Resource` for data types with extended range of valid values. `Resource` and `Resource` contain the following date components: -* Year (for `Resource` 12 bits, unsigned; for `Resource` 19 bits, signed); -* Month (4 bits); -* Day (5 bits); -* Hour (5 bits); -* Minute (6 bits); -* Second (6 bits); -* Microsecond (20 bits); -* TimezoneId (16 bits); -* DayOfYear (9 bits): Day since the beginning of the year; -* WeekOfYear (6 bits): Week since the beginning of the year, January 1 is always in week 1; -* WeekOfYearIso8601 (6 bits): Week of the year according to ISO 8601 (the first week is the one that includes January 4); -* DayOfWeek (3 bits): Day of the week. +* Year (for `Resource` 12 bits, unsigned; for `Resource` 19 bits, signed) +* Month (4 bits) +* Day (5 bits) +* Hour (5 bits) +* Minute (6 bits) +* Second (6 bits) +* Microsecond (20 bits) +* TimezoneId (16 bits) +* DayOfYear (9 bits): Day since the beginning of the year +* WeekOfYear (6 bits): Week since the beginning of the year, January 1 is always in week 1 +* WeekOfYearIso8601 (6 bits): Week of the year according to ISO 8601 (the first week is the one that includes January 4) +* DayOfWeek (3 bits): Day of the week If the timezone is not GMT, the components store the local time for the relevant timezone. @@ -41,8 +41,8 @@ Conversion from a {{ ydb-short-name }} primitive type to the [internal represent ### List of functions -* `DateTime::Split(Date/TzDate/Datetime/TzDatetime/Timestamp/TzTimestamp{Flags:AutoMap}) -> Resource`; -* `DateTime::Split(Date32/TzDate32/Datetime64/TzDatetime64/Timestamp64/TzTimestamp64{Flags:AutoMap}) -> Resource`. +* `DateTime::Split(Date/TzDate/Datetime/TzDatetime/Timestamp/TzTimestamp{Flags:AutoMap}) -> Resource` +* `DateTime::Split(Date32/TzDate32/Datetime64/TzDatetime64/Timestamp64/TzTimestamp64{Flags:AutoMap}) -> Resource` Functions that accept `Resource` or `Resource` as input can be called directly from the primitive date/time type. In this case, an implicit conversion will be made by calling the corresponding `Split` function. @@ -53,16 +53,16 @@ Creating a {{ ydb-short-name }} primitive type from the [internal representation ### List of functions * `DateTime::MakeDate(Resource{Flags:AutoMap}) -> Date` -* `DateTime::MakeDate32(Resource{Flags:AutoMap}) -> Date32`; -* `DateTime::MakeTzDate32(Resource{Flags:AutoMap}) -> TzDate32`; -* `DateTime::MakeDatetime(Resource{Flags:AutoMap}) -> Datetime`; -* `DateTime::MakeTzDatetime(Resource{Flags:AutoMap}) -> TzDatetime`; -* `DateTime::MakeDatetime64(Resource{Flags:AutoMap}) -> Datetime64`; -* `DateTime::MakeTzDatetime64(Resource{Flags:AutoMap}) -> TzDatetime64`; -* `DateTime::MakeTimestamp(Resource{Flags:AutoMap}) -> Timestamp`; -* `DateTime::MakeTzTimestamp(Resource{Flags:AutoMap}) -> TzTimestamp`; -* `DateTime::MakeTimestamp64(Resource{Flags:AutoMap}) -> Timestamp64`; -* `DateTime::MakeTzTimestamp64(Resource{Flags:AutoMap}) -> TzTimestamp64`. +* `DateTime::MakeDate32(Resource{Flags:AutoMap}) -> Date32` +* `DateTime::MakeTzDate32(Resource{Flags:AutoMap}) -> TzDate32` +* `DateTime::MakeDatetime(Resource{Flags:AutoMap}) -> Datetime` +* `DateTime::MakeTzDatetime(Resource{Flags:AutoMap}) -> TzDatetime` +* `DateTime::MakeDatetime64(Resource{Flags:AutoMap}) -> Datetime64` +* `DateTime::MakeTzDatetime64(Resource{Flags:AutoMap}) -> TzDatetime64` +* `DateTime::MakeTimestamp(Resource{Flags:AutoMap}) -> Timestamp` +* `DateTime::MakeTzTimestamp(Resource{Flags:AutoMap}) -> TzTimestamp` +* `DateTime::MakeTimestamp64(Resource{Flags:AutoMap}) -> Timestamp64` +* `DateTime::MakeTzTimestamp64(Resource{Flags:AutoMap}) -> TzTimestamp64` ### Examples @@ -84,23 +84,23 @@ Extracting a component from the [internal representation](#resource). ### List of functions -* `DateTime::GetYear(Resource{Flags:AutoMap}) -> Uint16`; -* `DateTime::GetYear(Resource{Flags:AutoMap}) -> Int32`; -* `DateTime::GetDayOfYear(Resource/Resource{Flags:AutoMap}) -> Uint16`; -* `DateTime::GetMonth(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetMonthName(Resource/Resource{Flags:AutoMap}) -> String`; -* `DateTime::GetWeekOfYear(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetWeekOfYearIso8601(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetDayOfMonth(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetDayOfWeek(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetDayOfWeekName(Resource/Resource{Flags:AutoMap}) -> String`; -* `DateTime::GetHour(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetMinute(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetSecond(Resource/Resource{Flags:AutoMap}) -> Uint8`; -* `DateTime::GetMillisecondOfSecond(Resource/Resource{Flags:AutoMap}) -> Uint32`; -* `DateTime::GetMicrosecondOfSecond(Resource/Resource{Flags:AutoMap}) -> Uint32`; -* `DateTime::GetTimezoneId(Resource/Resource{Flags:AutoMap}) -> Uint16`; -* `DateTime::GetTimezoneName(Resource/Resource{Flags:AutoMap}) -> String`. +* `DateTime::GetYear(Resource{Flags:AutoMap}) -> Uint16` +* `DateTime::GetYear(Resource{Flags:AutoMap}) -> Int32` +* `DateTime::GetDayOfYear(Resource/Resource{Flags:AutoMap}) -> Uint16` +* `DateTime::GetMonth(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetMonthName(Resource/Resource{Flags:AutoMap}) -> String` +* `DateTime::GetWeekOfYear(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetWeekOfYearIso8601(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetDayOfMonth(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetDayOfWeek(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetDayOfWeekName(Resource/Resource{Flags:AutoMap}) -> String` +* `DateTime::GetHour(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetMinute(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetSecond(Resource/Resource{Flags:AutoMap}) -> Uint8` +* `DateTime::GetMillisecondOfSecond(Resource/Resource{Flags:AutoMap}) -> Uint32` +* `DateTime::GetMicrosecondOfSecond(Resource/Resource{Flags:AutoMap}) -> Uint32` +* `DateTime::GetTimezoneId(Resource/Resource{Flags:AutoMap}) -> Uint16` +* `DateTime::GetTimezoneName(Resource/Resource{Flags:AutoMap}) -> String` ### Examples @@ -148,12 +148,12 @@ Getting a Timestamp from the number of seconds/milliseconds/microseconds since t ### List of functions -* `DateTime::FromSeconds(Uint32{Flags:AutoMap}) -> Timestamp`; -* `DateTime::FromSeconds64(Int64{Flags:AutoMap}) -> Timestamp64`; -* `DateTime::FromMilliseconds(Uint64{Flags:AutoMap}) -> Timestamp`; -* `DateTime::FromMilliseconds64(Int64{Flags:AutoMap}) -> Timestamp64`; -* `DateTime::FromMicroseconds(Uint64{Flags:AutoMap}) -> Timestamp`; -* `DateTime::FromMicroseconds64(Int64{Flags:AutoMap}) -> Timestamp64`. +* `DateTime::FromSeconds(Uint32{Flags:AutoMap}) -> Timestamp` +* `DateTime::FromSeconds64(Int64{Flags:AutoMap}) -> Timestamp64` +* `DateTime::FromMilliseconds(Uint64{Flags:AutoMap}) -> Timestamp` +* `DateTime::FromMilliseconds64(Int64{Flags:AutoMap}) -> Timestamp64` +* `DateTime::FromMicroseconds(Uint64{Flags:AutoMap}) -> Timestamp` +* `DateTime::FromMicroseconds64(Int64{Flags:AutoMap}) -> Timestamp64` ## To... {#to} @@ -161,12 +161,12 @@ Getting a number of seconds/milliseconds/microseconds since the UTC Epoch from a ### List of functions -* `DateTime::ToSeconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint32`; -* `DateTime::ToSeconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64`; -* `DateTime::ToMilliseconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64`; -* `DateTime::ToMilliseconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64`; -* `DateTime::ToMicroseconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64`; -* `DateTime::ToMicroseconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64`. +* `DateTime::ToSeconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint32` +* `DateTime::ToSeconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64` +* `DateTime::ToMilliseconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64` +* `DateTime::ToMilliseconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64` +* `DateTime::ToMicroseconds(Date/Datetime/Timestamp/TzDate/TzDatetime/TzTimestamp{Flags:AutoMap}) -> Uint64` +* `DateTime::ToMicroseconds(Date32/Datetime64/Timestamp64/TzDate32/TzDatetime64/TzTimestamp64{Flags:AutoMap}) -> Int64` ### Examples @@ -182,30 +182,30 @@ Conversions between `Interval` and various time units. ### List of functions -* `DateTime::ToDays(Interval{Flags:AutoMap}) -> Int32`; -* `DateTime::ToDays(Interval64{Flags:AutoMap}) -> Int32`; -* `DateTime::ToHours(Interval{Flags:AutoMap}) -> Int32`; -* `DateTime::ToHours(Interval64{Flags:AutoMap}) -> Int64`; -* `DateTime::ToMinutes(Interval{Flags:AutoMap}) -> Int32`; -* `DateTime::ToMinutes(Interval64{Flags:AutoMap}) -> Int64`; -* `DateTime::ToSeconds(Interval{Flags:AutoMap}) -> Int64`; -* `DateTime::ToSeconds(Interval64{Flags:AutoMap}) -> Int64`; -* `DateTime::ToMilliseconds(Interval{Flags:AutoMap}) -> Int64`; -* `DateTime::ToMilliseconds(Interval64{Flags:AutoMap}) -> Int64`; -* `DateTime::ToMicroseconds(Interval{Flags:AutoMap}) -> Int64`; -* `DateTime::ToMicroseconds(Interval64{Flags:AutoMap}) -> Int64`; -* `DateTime::IntervalFromDays(Int32{Flags:AutoMap}) -> Interval`; -* `DateTime::Interval64FromDays(Int32{Flags:AutoMap}) -> Interval64`; -* `DateTime::IntervalFromHours(Int32{Flags:AutoMap}) -> Interval`; -* `DateTime::Interval64FromHours(Int64{Flags:AutoMap}) -> Interval64`; -* `DateTime::IntervalFromMinutes(Int32{Flags:AutoMap}) -> Interval`; -* `DateTime::Interval64FromMinutes(Int64{Flags:AutoMap}) -> Interval64`; -* `DateTime::IntervalFromSeconds(Int64{Flags:AutoMap}) -> Interval`; -* `DateTime::Interval64FromSeconds(Int64{Flags:AutoMap}) -> Interval64`; -* `DateTime::IntervalFromMilliseconds(Int64{Flags:AutoMap}) -> Interval`; -* `DateTime::Interval64FromMilliseconds(Int64{Flags:AutoMap}) -> Interval64`; -* `DateTime::IntervalFromMicroseconds(Int64{Flags:AutoMap}) -> Interval`; -* `DateTime::Interval64FromMicroseconds(Int64{Flags:AutoMap}) -> Interval64`. +* `DateTime::ToDays(Interval{Flags:AutoMap}) -> Int32` +* `DateTime::ToDays(Interval64{Flags:AutoMap}) -> Int32` +* `DateTime::ToHours(Interval{Flags:AutoMap}) -> Int32` +* `DateTime::ToHours(Interval64{Flags:AutoMap}) -> Int64` +* `DateTime::ToMinutes(Interval{Flags:AutoMap}) -> Int32` +* `DateTime::ToMinutes(Interval64{Flags:AutoMap}) -> Int64` +* `DateTime::ToSeconds(Interval{Flags:AutoMap}) -> Int64` +* `DateTime::ToSeconds(Interval64{Flags:AutoMap}) -> Int64` +* `DateTime::ToMilliseconds(Interval{Flags:AutoMap}) -> Int64` +* `DateTime::ToMilliseconds(Interval64{Flags:AutoMap}) -> Int64` +* `DateTime::ToMicroseconds(Interval{Flags:AutoMap}) -> Int64` +* `DateTime::ToMicroseconds(Interval64{Flags:AutoMap}) -> Int64` +* `DateTime::IntervalFromDays(Int32{Flags:AutoMap}) -> Interval` +* `DateTime::Interval64FromDays(Int32{Flags:AutoMap}) -> Interval64` +* `DateTime::IntervalFromHours(Int32{Flags:AutoMap}) -> Interval` +* `DateTime::Interval64FromHours(Int64{Flags:AutoMap}) -> Interval64` +* `DateTime::IntervalFromMinutes(Int32{Flags:AutoMap}) -> Interval` +* `DateTime::Interval64FromMinutes(Int64{Flags:AutoMap}) -> Interval64` +* `DateTime::IntervalFromSeconds(Int64{Flags:AutoMap}) -> Interval` +* `DateTime::Interval64FromSeconds(Int64{Flags:AutoMap}) -> Interval64` +* `DateTime::IntervalFromMilliseconds(Int64{Flags:AutoMap}) -> Interval` +* `DateTime::Interval64FromMilliseconds(Int64{Flags:AutoMap}) -> Interval64` +* `DateTime::IntervalFromMicroseconds(Int64{Flags:AutoMap}) -> Interval` +* `DateTime::Interval64FromMicroseconds(Int64{Flags:AutoMap}) -> Interval64` `AddTimezone` doesn't affect the output of `ToSeconds()` in any way, because `ToSeconds()` always returns GMT time. @@ -232,30 +232,30 @@ Get the start (end) of the period including the date/time. If the result is inva ### List of functions -* `DateTime::StartOfYear(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfYear(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfYear(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfYear(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfQuarter(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfMonth(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfMonth(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfMonth(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfMonth(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfWeek(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfWeek(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfWeek(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfWeek(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfDay(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOfDay(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfDay(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOfDay(Resource{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?`; -* `DateTime::StartOf(Resource{Flags:AutoMap}, Interval64{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?`; -* `DateTime::EndOf(Resource{Flags:AutoMap}, Interval64{Flags:AutoMap}) -> Resource?`. +* `DateTime::StartOfYear(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfYear(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfYear(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfYear(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfQuarter(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfQuarter(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfQuarter(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfQuarter(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfMonth(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfMonth(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfMonth(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfMonth(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfWeek(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfWeek(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfWeek(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfWeek(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfDay(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOfDay(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfDay(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOfDay(Resource{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?` +* `DateTime::StartOf(Resource{Flags:AutoMap}, Interval64{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOf(Resource{Flags:AutoMap}, Interval{Flags:AutoMap}) -> Resource?` +* `DateTime::EndOf(Resource{Flags:AutoMap}, Interval64{Flags:AutoMap}) -> Resource?` The `StartOf`/`EndOf` functions are intended for grouping by an arbitrary period within a day. The result differs from the input value only by time components. A period exceeding one day is treated as a day (an equivalent of `StartOfDay`/`EndOfDay`). If a day doesn't include an integer number of periods, the number is rounded to the nearest time from the beginning of the day that is a multiple of the specified period. When the interval is zero, the output is same as the input. A negative interval is treated as a positive one. @@ -263,8 +263,8 @@ The `EndOf...` functions are intended for obtaining the latest moment in the sam The functions treat periods longer than one day in a different manner than the same-name functions in the old library. The time components are always reset to zero (this makes sense, because these functions are mainly used for grouping by the period). You can also specify a time period within a day: -* `DateTime::TimeOfDay(Resource{Flags:AutoMap}) -> Interval`; -* `DateTime::TimeOfDay(Resource{Flags:AutoMap}) -> Interval64`. +* `DateTime::TimeOfDay(Resource{Flags:AutoMap}) -> Interval` +* `DateTime::TimeOfDay(Resource{Flags:AutoMap}) -> Interval64` ### Examples @@ -301,12 +301,12 @@ Returns either an updated copy or NULL, if an update produces an invalid date or ### List of functions -* `DateTime::ShiftYears(Resource{Flags:AutoMap}, Int32) -> Resource?`; -* `DateTime::ShiftYears(Resource{Flags:AutoMap}, Int32) -> Resource?`; -* `DateTime::ShiftQuarters(Resource{Flags:AutoMap}, Int32) -> Resource?`; -* `DateTime::ShiftQuarters(Resource{Flags:AutoMap}, Int32) -> Resource?`; -* `DateTime::ShiftMonths(Resource{Flags:AutoMap}, Int32) -> Resource?`; -* `DateTime::ShiftMonths(Resource{Flags:AutoMap}, Int32) -> Resource?`. +* `DateTime::ShiftYears(Resource{Flags:AutoMap}, Int32) -> Resource?` +* `DateTime::ShiftYears(Resource{Flags:AutoMap}, Int32) -> Resource?` +* `DateTime::ShiftQuarters(Resource{Flags:AutoMap}, Int32) -> Resource?` +* `DateTime::ShiftQuarters(Resource{Flags:AutoMap}, Int32) -> Resource?` +* `DateTime::ShiftMonths(Resource{Flags:AutoMap}, Int32) -> Resource?` +* `DateTime::ShiftMonths(Resource{Flags:AutoMap}, Int32) -> Resource?` If the resulting number of the day in the month exceeds the maximum allowed, then the `Day` field will accept the last day of the month without changing the time (see examples). @@ -335,17 +335,17 @@ Get a string representation of a time using an arbitrary formatting string. A set of specifiers is implemented for the formatting string: -* `%%`: % character; -* `%Y`: year, 1–6 digits and sign for BC dates; -* `%m`: 2-digit month; -* `%d`: 2-digit day; -* `%H`: 2-digit hour; -* `%M`: 2-digit minutes; -* `%S`: 2-digit seconds or `XX.XXXXXX` in the case of non-empty microseconds (only if `alwaysWriteFractionalSeconds` is not set to `True`); -* `%z`: `+hhmm` or `-hhmm`; -* `%Z`: IANA name of the timezone; -* `%b`: A short three-letter English name of the month (Jan); -* `%B`: A full English name of the month (January). +* `%%`: % character +* `%Y`: year, 1–6 digits and sign for BC dates +* `%m`: 2-digit month +* `%d`: 2-digit day +* `%H`: 2-digit hour +* `%M`: 2-digit minutes +* `%S`: 2-digit seconds or `XX.XXXXXX` in the case of non-empty microseconds (only if `alwaysWriteFractionalSeconds` is not set to `True`) +* `%z`: `+hhmm` or `-hhmm` +* `%Z`: IANA name of the timezone +* `%b`: A short three-letter English name of the month (Jan) +* `%B`: A full English name of the month (January) All other characters in the format string are passed on without changes. @@ -365,21 +365,21 @@ Parse a string into an internal representation using an arbitrary formatting str ### List of functions -* `DateTime::Parse(String) -> (String{Flags:AutoMap}) -> Resource?`; -* `DateTime::Parse64(String) -> (String{Flags:AutoMap}) -> Resource?`. +* `DateTime::Parse(String) -> (String{Flags:AutoMap}) -> Resource?` +* `DateTime::Parse64(String) -> (String{Flags:AutoMap}) -> Resource?` Implemented specifiers: -* `%%`: the % character; -* `%Y`: 4-digit year when using `Parse`, or 1–6 digits and sign for BC dates when using `Parse64`; -* `%m`: 2-digit month; -* `%d`: 2-digit day; -* `%H`: 2-digit hour; -* `%M`: 2-digit minutes; -* `%S`: Seconds, can also accept microseconds in the formats from `XX` up to `XX.XXXXXX`; -* `%Z`: The IANA name of the timezone (e.g., GMT); -* `%b`: A short three-letter case-insensitive English name of the month (e.g., Jan); -* `%B`: A full case-insensitive English name of the month (January). +* `%%`: the % character +* `%Y`: 4-digit year when using `Parse`, or 1–6 digits and sign for BC dates when using `Parse64` +* `%m`: 2-digit month +* `%d`: 2-digit day +* `%H`: 2-digit hour +* `%M`: 2-digit minutes +* `%S`: Seconds, can also accept microseconds in the formats from `XX` up to `XX.XXXXXX` +* `%Z`: The IANA name of the timezone (e.g., GMT) +* `%b`: A short three-letter case-insensitive English name of the month (e.g., Jan) +* `%B`: A full case-insensitive English name of the month (January) ### Examples @@ -404,10 +404,10 @@ For the common formats, wrappers around the corresponding util methods are suppo ### List of functions -* `DateTime::ParseRfc822(String{Flags:AutoMap}) -> Resource?`; -* `DateTime::ParseIso8601(String{Flags:AutoMap}) -> Resource?`; -* `DateTime::ParseHttp(String{Flags:AutoMap}) -> Resource?`; -* `DateTime::ParseX509(String{Flags:AutoMap}) -> Resource?`. +* `DateTime::ParseRfc822(String{Flags:AutoMap}) -> Resource?` +* `DateTime::ParseIso8601(String{Flags:AutoMap}) -> Resource?` +* `DateTime::ParseHttp(String{Flags:AutoMap}) -> Resource?` +* `DateTime::ParseX509(String{Flags:AutoMap}) -> Resource?` ### Examples @@ -544,7 +544,7 @@ SELECT CAST(TzDatetime("1970-01-01T23:59:59,Europe/Moscow") as TzDate); There is no valid value, starting from the Unix epoch, that can represent midnight on 01/01/1970 for the Moscow timezone. As a result, such a cast is considered impossible and generates a runtime error. -At the same time, values with a negative timezone offset return a correct result: +However, values with a negative timezone offset return a correct result: ```yql SELECT CAST(TzDatetime("1970-01-01T23:59:59,America/Los_Angeles") as TzDate); @@ -553,7 +553,7 @@ SELECT CAST(TzDatetime("1970-01-01T23:59:59,America/Los_Angeles") as TzDate); ### Daylight saving time -Please note that daylight saving time depends on the year: +Note that daylight saving time depends on the year: ```yql SELECT From 47a36cbebdf41af72c135d5a105aabd01efdbc70 Mon Sep 17 00:00:00 2001 From: Anton Bobkov Date: Wed, 24 Sep 2025 13:16:28 +0300 Subject: [PATCH 3/4] Deleted a link to a missing file --- ydb/docs/en/core/yql/reference/types/primitive.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ydb/docs/en/core/yql/reference/types/primitive.md b/ydb/docs/en/core/yql/reference/types/primitive.md index dcfeaa72ea34..b6aa282e47a9 100644 --- a/ydb/docs/en/core/yql/reference/types/primitive.md +++ b/ydb/docs/en/core/yql/reference/types/primitive.md @@ -87,7 +87,7 @@ Doesn't support matching{% if feature_map_tables %}, can't be used in the primar Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} || || `Yson` | -[YSON](yson.md) in textual or binary representation | +YSON in textual or binary representation | Doesn't support matching{% if feature_map_tables %}, can't be used in the primary key or in columns that form the key of a secondary index{% endif %} || || `Uuid` | @@ -458,4 +458,4 @@ When numeric types don't match, first BitCast of both arguments to the result ty | **Interval64** | — | — | — | — | — | — | — | — | — | — | — | — | — | — | | **TzDate32** | — | — | — | — | — | — | — | — | — | — | — | — | `TzDatetime64` | `TzTimestamp64` | | **TzDatetime64** | — | — | — | — | — | — | — | — | — | — | — | — | — | `TzTimestamp64` | -| **TzTimestamp64** | — | — | — | — | — | — | — | — | — | — | — | — | — | — | \ No newline at end of file +| **TzTimestamp64** | — | — | — | — | — | — | — | — | — | — | — | — | — | — | From 7351f40eaac9490608038499d7fce2b02cca93ee Mon Sep 17 00:00:00 2001 From: Anton Bobkov Date: Mon, 29 Sep 2025 12:50:04 +0300 Subject: [PATCH 4/4] Readded changes from Commit d10b8c7 --- ydb/docs/en/core/yql/reference/types/primitive.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ydb/docs/en/core/yql/reference/types/primitive.md b/ydb/docs/en/core/yql/reference/types/primitive.md index b6aa282e47a9..228aa932f54e 100644 --- a/ydb/docs/en/core/yql/reference/types/primitive.md +++ b/ydb/docs/en/core/yql/reference/types/primitive.md @@ -13,6 +13,7 @@ Notes || || `Bool` | Boolean value | +Not available for column-oriented tables || || `Int8` | Signed integer @@ -62,7 +63,7 @@ Real number with fixed precision, 16 bytes in size. Precision is the maximum tot || `DyNumber` | Binary representation of a real number with precision up to 38 digits. | Acceptable values: positive from 1×10-130 to 1×10126–1, negative from -1×10126–1 to -1×10-130 and 0. -Compatible with the `Number` type in AWS DynamoDB. Not recommended for use in {{ backend_name_lower }}-native applications. | +Compatible with the `Number` type in AWS DynamoDB. Not recommended for use in {{ backend_name_lower }}-native applications. Not available for column-oriented tables. | || {% endif %} |# @@ -92,6 +93,7 @@ Doesn't support matching{% if feature_map_tables %}, can't be used in the primar || || `Uuid` | Universal identifier [UUID](https://tools.ietf.org/html/rfc4122) | +Not available for column-oriented tables || |# @@ -201,7 +203,7 @@ from -136 years to +136 years | 8 | -{% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index.{% else %}—{% endif %} +{% if feature_map_tables %}Can't be used in the primary key or in columns that form the key of a secondary index.{% else %}—{% endif %} Not available for column-oriented tables || ||