ClickHouse doc says DateTime is an instant in time. But in actual client's response Array(DateTime) represents as LocalDateTime[] (or more accurete ClickHouseArrayValue<LocalDateTime>) so without additional information it is imposible to convert it in collection of java.time.Instant.
At the same time simple DateTime value represents as ClickHouseDateTimeValue which stores TimeZone and correctly converts via asInstant()
So my question is: Is there a way to get Array(DateTime) as Instant[]?
For now I can see 2 workarounds:
Share ClickHouseConfig with use_time_zone: ... and use LocalDateTime::atZone(...), but it does not solve problem when use_server_time_zone: true
Rewrite queries with arrayMap(toUnixTimestamp, ...)
Example for clearness:
Here I requests same DateTime using clients with different settings
With getInstantExample() is everything OK
But how to get timestamp in getInstantArrayExample()?
Problem:
ClickHouse doc says DateTime is an instant in time. But in actual client's response
Array(DateTime)
represents asLocalDateTime[]
(or more accureteClickHouseArrayValue<LocalDateTime>
) so without additional information it is imposible to convert it in collection ofjava.time.Instant
. At the same time simpleDateTime
value represents asClickHouseDateTimeValue
which storesTimeZone
and correctly converts viaasInstant()
So my question is: Is there a way to get
Array(DateTime)
asInstant[]
?For now I can see 2 workarounds:
ClickHouseConfig
withuse_time_zone: ...
and useLocalDateTime::atZone(...)
, but it does not solve problem whenuse_server_time_zone: true
arrayMap(toUnixTimestamp, ...)
Example for clearness:
Here I requests same
DateTime
using clients with different settings WithgetInstantExample()
is everything OK But how to get timestamp ingetInstantArrayExample()
?Configuration
Environment
ClickHouse server