trino
trino copied to clipboard
Fix CTAS for Clickhouse TimestampWithTimeZone
The time zone is not stored in the rows of the table, but is stored in the column metadata.
From ClickHouse documentation https://clickhouse.com/docs/en/sql-reference/data-types/datetime
The point in time is saved as a Unix timestamp, regardless of the time zone or daylight saving time. The time zone affects how the values of the DateTime type values are displayed in text format and how the values specified as strings are parsed (‘2020-01-01 05:00:01’).
Timezone agnostic Unix timestamp is stored in tables, and the timezone is used to transform it to text format or back during data import/export or to make calendar calculations on the values (example: toDate, toHour functions etc.). The time zone is not stored in the rows of the table (or in resultset), but is stored in the column metadata.
Description
Additional context and related issues
- https://github.com/trinodb/trino/issues/7100
- https://github.com/trinodb/trino/issues/10537
- https://github.com/trinodb/trino/pull/15040
PRs:
- https://github.com/trinodb/trino/pull/23460
- https://github.com/trinodb/trino/pull/23785
- https://github.com/trinodb/trino/pull/23788
- https://github.com/trinodb/trino/pull/23789
- https://github.com/trinodb/trino/pull/23802
ClickHouse docs:
- https://clickhouse.com/docs/en/sql-reference/data-types/datetime
- https://clickhouse.com/docs/en/sql-reference/data-types/datetime64
Release notes
( ) This is not user-visible or is docs only, and no release notes are required. ( ) Release notes are required. Please propose a release note for me. (x) Release notes are required, with the following suggested text:
## Section
* Fix CTAS for Clickhouse TimestampWithTimeZone. ({issue}`issuenumber`)