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

Incorrect datetime/date returned #590

Closed
zhicwu opened this issue Mar 8, 2021 · 2 comments · Fixed by #589
Closed

Incorrect datetime/date returned #590

zhicwu opened this issue Mar 8, 2021 · 2 comments · Fixed by #589
Assignees
Labels
Milestone

Comments

@zhicwu
Copy link
Contributor

zhicwu commented Mar 8, 2021

ClickHouse stores datetime as Unix timestamp, and timezone in column metadata. So timzone will only affect datetime value in string format during parsing and displaying. As ClickHouse server does not support custom timezone in http interface(only X-ClickHouse-Timezone header in response, which represents server timezone), it uses column/server timezone to format datetime values and returned in text format like TabSeparatedWithNamesAndTypes(which is relied by JDBC driver). Unfortunately this does not work when ClickHouse server uses non-UTC timezone, and JDBC client with use_server_time_zone set to false is in a different timezone. On the other hand, changing date_time_output_format to 'unix_timestamp' can avoid this issue, but it's not default and it may cause more issues since JDBC driver didn't consider that.

In order to fix the timezone issue:

  • take below workaround in 0.3.x (consider date_time_output_format when parsing)
    • re-format datetime string returned from server(parse using column/server timezone, and then re-format using client timezone)
  • switch to RowBinary format starting from 0.3.1 for permanent fix
@zhicwu zhicwu added the bug label Mar 8, 2021
@zhicwu zhicwu added this to the 0.3.0 release milestone Mar 8, 2021
@zhicwu zhicwu mentioned this issue Mar 8, 2021
@zhicwu zhicwu self-assigned this Mar 8, 2021
@zhicwu zhicwu linked a pull request Mar 8, 2021 that will close this issue
@zhicwu
Copy link
Contributor Author

zhicwu commented Mar 8, 2021

Link to ClickHouse/ClickHouse#4548

@zhicwu
Copy link
Contributor Author

zhicwu commented Mar 12, 2021

Will permanently fix the issue by switching to RowBinary protocol in #476.

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

Successfully merging a pull request may close this issue.

1 participant