Comments (5)
This is a correct and expected result.
Timezone is a property of a column not of a value. A column can have only one timezone.
The timezone from the first select is used.
from clickhouse.
Also 1714551897000 it's not a DateTime, it's DateTime64.
https://fiddle.clickhouse.com/498612af-5194-410c-85d0-ea7e00aba2ee
from clickhouse.
This is a correct and expected result. Timezone is a property of a column not of a value. A column can have only one timezone. The timezone from the first select is used.
Hi, thanks, but why use literal time string it's also right:
WITH '2024-05-01 16:24:57' AS date_value
SELECT
'UTC-12',
toDateTime(date_value, 'Etc/GMT+12')
UNION ALL
SELECT
'UTC-11',
toDateTime(date_value, 'Pacific/Midway')
UNION ALL
SELECT
'UTC-10',
toDateTime(date_value, 'Pacific/Honolulu')
Query id: 891b449f-c9b8-42de-929e-4990bf857c71
┌─'UTC-12'─┬─toDateTime(date_value, 'Etc/GMT+12')─┐
1. │ UTC-12 │ 2024-05-01 16:24:57 │
└──────────┴──────────────────────────────────────┘
┌─'UTC-12'─┬─toDateTime(date_value, 'Etc/GMT+12')─┐
2. │ UTC-11 │ 2024-05-01 15:24:57 │
└──────────┴──────────────────────────────────────┘
┌─'UTC-12'─┬─toDateTime(date_value, 'Etc/GMT+12')─┐
3. │ UTC-10 │ 2024-05-01 14:24:57 │
└──────────┴──────────────────────────────────────┘
from clickhouse.
Hi, thanks, but why use literal time string it's also right:
Because TZ is property of datetime type and its value is numeric (timestamp - number of ticks since the beginning of the epoch in UTC). TZ is used during the parsing of strings and during the rendering numeric values back to strings.
So in case of toDateTime('2024-05-01 16:24:57', 'Pacific/Midway')
-> string form '2024-05-01 16:24:57'
is converted using Pacific/Midway
and the result is type DateTime('Pacific/Midway')
.
And in case of toDateTime(1714551897, 'Pacific/Midway')
-> numeric value is placed into a datetime value without using TZ with the type DateTime('Pacific/Midway')
.
In other words Clickhouse treats numbers 1714551897 as a fully prepared timestamp in UTC TZ. And strings '2024-05-01 16:24:57' as not prepared value which should be converted into a timestamp using TZ.
from clickhouse.
Got you, thanks.
from clickhouse.
Related Issues (20)
- Test `test_storage_s3_queue/test.py::test_multiple_tables_streaming_sync_distributed` is flaky HOT 3
- Test `test_broken_projections/test.py::test_broken_ignored_replicated` is flaky
- Inconsistent formatting: query `SELECT NOT((SELECT 1))` cannot parse back
- finalizeAggregation does not work correctly with groupArrayIntersect aggregate function on 24.7.1.2730 (current head) HOT 1
- Test `02911_backup_restore_keeper_map` is flaky HOT 2
- Test `test_broken_projections/test.py::test_broken_projections_in_backups_1` is flaky
- Query too slow when using allow_experimental_analyzer=1 HOT 2
- How To Backup/Restore While Preserving Disk For Partition HOT 1
- Flaky `test_runtime_configurable_cache_size` HOT 5
- LOGICAL_ERROR: Format {} doesn't support schema inference HOT 9
- Segmentation Fault in ClickHouse 24.6.2.17 with Concurrent Queries on AWS ECS Using Official ARM64 Docker Image HOT 5
- Lightweight deletes using subqueries significantly slower in 24.3 HOT 5
- Query with parallel replicas may deadlock on cancel
- [Rust Client] Can not INSERT any data from the Rust client. HOT 2
- Data race on global context between merge and query processing in clickhouse-local HOT 2
- Inconsistent Results with CAST for DateTime64 HOT 1
- Granting role usage of dictionary table function does not work
- The test `02581_share_big_sets_between_multiple_mutations_tasks_long.sql` consumes a lot of memory. HOT 1
- Cannot schedule a task: cannot allocate thread HOT 2
- crash when I set max_thread_pool_size to 100000 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clickhouse.