Repository navigation
Have chDB use postgres session's TimeZone #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,72 @@ SELECT pg_read_file(:'tsv_path'); | |
|
|
||
| (1 row) | ||
|
|
||
| /************************ No offset ************************/ | ||
| -- Text without offset reads as wall clock in Postgres timezone for timestamp, | ||
| -- UTC for timestamptz. ts stays 12:00 under every timezone. | ||
| \set naive_path :temp_dir /naive.tsv | ||
| \set naive_url file:// :naive_path | ||
| CREATE TABLE naive (id INT, ts TEXT, tstz TEXT); | ||
| INSERT INTO naive VALUES (1, '2026-08-28 12:00:00', '2026-08-28 12:00:00'); | ||
| COPY naive TO :'naive_url'; | ||
| SET timezone TO 'America/Los_Angeles'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the default in pg_regress, FWIW. |
||
| TRUNCATE dt2; | ||
| COPY dt2 FROM :'naive_url'; | ||
| SELECT * FROM dt2; | ||
| id | ts | tstz | ||
| ----+---------------------+------------------------ | ||
| 1 | 2026-08-28 12:00:00 | 2026-08-28 05:00:00-07 | ||
| (1 row) | ||
|
|
||
| SET timezone TO 'Asia/Tokyo'; | ||
| TRUNCATE dt2; | ||
| COPY dt2 FROM :'naive_url'; | ||
| SELECT * FROM dt2; | ||
| id | ts | tstz | ||
| ----+---------------------+------------------------ | ||
| 1 | 2026-08-28 12:00:00 | 2026-08-28 21:00:00+09 | ||
|
theory marked this conversation as resolved.
Resolved
|
||
| (1 row) | ||
|
|
||
| -- Fixed offset, which chDB spells Fixed/UTC-07:00:00 | ||
| SET TIME ZONE -7; | ||
| TRUNCATE dt2; | ||
| COPY dt2 FROM :'naive_url'; | ||
| SELECT * FROM dt2; | ||
| id | ts | tstz | ||
| ----+---------------------+------------------------ | ||
| 1 | 2026-08-28 12:00:00 | 2026-08-28 05:00:00-07 | ||
| (1 row) | ||
|
|
||
| SET timezone TO 'UTC'; | ||
| /************************ Declared precision ************************/ | ||
| -- Inferred structure takes fractional digits from column typmod. | ||
| CREATE TABLE precisions ( | ||
| ts TIMESTAMP(3) NOT NULL, | ||
| tstz TIMESTAMPTZ(1) NOT NULL, | ||
| t TIME(4) NOT NULL, | ||
| tn TIME(2) NULL | ||
| ); | ||
| INSERT INTO precisions | ||
| VALUES ('2026-07-23 20:43:27.363', '2026-07-23 20:43:50.9Z', '13:45:24.2821', '13:45:24.28'); | ||
| COPY precisions TO :'tsv_url'; | ||
| SELECT pg_read_file(:'tsv_path'); | ||
| pg_read_file | ||
| ------------------------------------------------------------------------------------- | ||
| 2026-07-23T20:43:27.363Z 2026-07-23T20:43:50.9Z 13:45:24.2821 13:45:24.28+ | ||
|
theory marked this conversation as resolved.
Resolved
|
||
|
|
||
| (1 row) | ||
|
|
||
| -- Parquet replaces parameterized Time64 with String. | ||
| \set parquet_url file:// :temp_dir /precisions.parquet | ||
| COPY precisions TO :'parquet_url' (format 'Parquet'); | ||
| TRUNCATE precisions; | ||
| COPY precisions FROM :'parquet_url' (format 'Parquet'); | ||
| SELECT * FROM precisions; | ||
| ts | tstz | t | tn | ||
| -------------------------+--------------------------+---------------+------------- | ||
| 2026-07-23 20:43:27.363 | 2026-07-23 20:43:50.9+00 | 13:45:24.2821 | 13:45:24.28 | ||
| (1 row) | ||
|
|
||
| /************************ Default scales ************************/ | ||
| -- A DateTime64 or Time64 named without a scale takes chDB's default of | ||
| -- milliseconds, truncating the microseconds Postgres holds. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule pg-clickhouse-c
updated
10 files
| +1 −1 | doc/pg-clickhouse-encode.md | |
| +4 −0 | doc/pg-clickhouse.md | |
| +43 −2 | pg-clickhouse.h | |
| +8 −0 | test/expected/errors.out | |
| +1 −1 | test/expected/type_table.out | |
| +45 −1 | test/expected/types.out | |
| +3 −0 | test/pgch_test--1.0.sql | |
| +8 −0 | test/pgch_test.c | |
| +7 −0 | test/sql/errors.sql | |
| +16 −0 | test/sql/types.sql |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.