Skip to content
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

Query settings session_timezone not being applied #1464

Closed
tecpcarrier opened this issue Oct 4, 2023 · 7 comments · Fixed by ClickHouse/ClickHouse#63377 or #1738
Closed

Query settings session_timezone not being applied #1464

tecpcarrier opened this issue Oct 4, 2023 · 7 comments · Fixed by ClickHouse/ClickHouse#63377 or #1738
Labels
Milestone

Comments

@tecpcarrier
Copy link

tecpcarrier commented Oct 4, 2023

Describe the bug

Clickhouse allows user to set query to multiple level including at the query level. When the setting session_timezone is set in dbeaver , the setting is not being picked up. I have looked at this issue #604 where the timezone is set correctly for toDateTime but it does not seem to be the case when using this setting. Whenever I use session_timezone, the datetime uses the wrong timezone.

image

In this query, the date should be identical to the second column not the third. Running it directly using clickhouse-client, the result of this query should be the following:

image

By changing the session_timezone, the value in the first column should change to adapt to the new timezone.

Configuration

ClickHouse server

  • ClickHouse Server version: 23.8.2.7
  • Statement:
WITH temp AS
    (
        SELECT 1696431276 AS date
    )
SELECT
    toDateTime(date),
    toDateTime(date, 'America/New_York'),
    toDateTime(date, 'UTC')
FROM temp
SETTINGS session_timezone = 'America/Vancouver'
@tecpcarrier tecpcarrier added the bug label Oct 4, 2023
@mohaidoss
Copy link

Hey any workaround @tecpcarrier ? I am having the same issue, and it's quite confusing since the following test is doing just fine with the JDBC...

SELECT toDateTime('2023-01-01 10:15:20') SETTINGS session_timezone = 'Etc/GMT+5'

image

@vladaman
Copy link

vladaman commented May 2, 2024

We are experiencing same issue. Seems like SETTINGS session_timezone = 'Etc/GMT+5' has no effect on result.

@den-crane
Copy link
Collaborator

The reason is in Clickhouse server

@mohaidoss
Copy link

@den-crane seems like the bug is fixed on versions >= 23.8 ?

@chernser
Copy link
Contributor

@mohaidoss There is a bug on client side - value from the server timezone header is not applied to results (only for RowBinary*)
I'm working on the fix.

@chernser
Copy link
Contributor

chernser commented Jul 23, 2024

Client today doesn't read X-Server-Timezone from a response.
The toDateTime('2023-10-04 10:54:36') will be in server or session timezone and thus no conversion should be:

SELECT
    toDateTime('2023-10-04 10:54:36'),
    serverTimezone(),
    timezone(),
    toDateTime('2023-10-04 10:54:36', 'UTC')
SETTINGS session_timezone = 'America/Los_Angeles'

Query id: d78c4447-fe88-40e4-9a61-7033f2069cb2

   ┌─toDateTime('2023-10-04 10:54:36')─┬─serverTimezone()─┬─timezone()──────────┬─toDateTime('2023-10-04 10:54:36', 'UTC')─┐
1. │               2023-10-04 10:54:36 │ UTC              │ America/Los_Angeles │                      2023-10-04 10:54:36 │
   └───────────────────────────────────┴──────────────────┴─────────────────────┴──────────────────────────────────────────┘

After the fix about the header client would convert all DateTime values that come without an offset into server timezone that is returned in response. However it will not affect values that have timezone already.
And this behavior will work only if client is configured to use server timezone.

@mohaidoss
Copy link

Thats Exciting @chernser. Let le know if I can be of help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants