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

Server time zone when use query_df #152

Closed
kizimenko opened this issue Mar 22, 2023 · 1 comment · Fixed by #156
Closed

Server time zone when use query_df #152

kizimenko opened this issue Mar 22, 2023 · 1 comment · Fixed by #156
Labels
bug Something isn't working

Comments

@kizimenko
Copy link

image

Driver does not apply server timezone when selecting dateTime column

Query: select timeZone()
Answer: Europe/Moscow

Code example

import clickhouse_connect

clickhouse-connect and/or ClickHouse server logs

Configuration

Environment

  • clickhouse-connect version: 0.5.16
  • Python version: 3.10
  • Operating system: Ubuntu

ClickHouse server

  • ClickHouse Server version: 22.12.1.1752
@kizimenko kizimenko added the bug Something isn't working label Mar 22, 2023
@genzgd
Copy link
Collaborator

genzgd commented Mar 22, 2023

Thanks for the report! It's true that by default clickhouse-connect returns timezone naive ClickHouse columns as UTC times. For other query_* methods you can override the timezone on the client side by using the query_tz parameter, but there is a bug in that parameter is not exposed for query_df. I'll get a fix for that in the next week or so.

In any case I think it makes sense to create setting that respects the server timezone, so we'll add that functionality in the next release as well. Just a warning that timezone conversions in Python are somewhat expensive, so I'd be inclined to leave the default for such a setting to use the current behavior of returning timezone naive UTC times regardless of server timezone.

@genzgd genzgd linked a pull request Mar 26, 2023 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants