-
Notifications
You must be signed in to change notification settings - Fork 559
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
Copy timezone from response if differs from config server_time_zone #1738
Conversation
Assert.assertTrue(Duration.between(serverTimeNow, nowAtTimezone).abs().getSeconds() < 60, | ||
"Server time (" + serverTimeNow + " ) should be close to the client time (" + nowAtTimezone + ")"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a daylight saving test as well
ZonedDateTime serverNowZoned = rs.getObject(1, ZonedDateTime.class); | ||
|
||
|
||
System.out.println("serverNow: " + serverNow + " tzTime: " + tzTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want these println messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to leave them, but I agree with you - tests should be clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beside no assertions - shame on me
Quality Gate failedFailed conditions |
Summary
By default java client will issue a pre-flight
select serverTimezone()
when creating a new connection and returned timezone will be used for conversion of returned DateTime values.Server returns its timezone in
X-ClickHouse-Timezone
header. This timezone is most accurate because it respectssession_timezone
setting. But this header value is not always used what causes double convertion to incorrect value.For example,
select now()
returns2024-07-18 20:30:58
for server in UTC timezoneselect now() settings session_timezone='America/Los_Angeles'
would return2024-07-18 13:30:58
andX-ClickHouse-Timezone: America/Los_Angeles
.But java client will parse that value into
LocalDateTime [2024-07-18 20:30:58]
assuming that server timezone is UTCThis PR makes Client check timezone from the header and override it in config for current query (that config will be used later by deserializer to convert date/time).
Closes #1464
Checklist
Delete items not relevant to your PR: