Skip to content

Commit 66220c7

Browse files
committed
refactor(clickhouse): clean up session timezone handling
1 parent 94ae16f commit 66220c7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ibis/backends/clickhouse/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import ast
44
import atexit
55
import glob
6-
import warnings
76
from contextlib import closing, suppress
87
from functools import partial
98
from typing import TYPE_CHECKING, Any, Literal
@@ -123,6 +122,7 @@ def do_connect(
123122
client_name: str = "ibis",
124123
secure: bool | None = None,
125124
compression: str | bool = True,
125+
settings: Mapping[str, Any] | None = None,
126126
**kwargs: Any,
127127
):
128128
"""Create a ClickHouse client for use with Ibis.
@@ -148,6 +148,8 @@ def do_connect(
148148
The kind of compression to use for requests. See
149149
https://clickhouse.com/docs/en/integrations/python#compression for
150150
more information.
151+
settings
152+
ClickHouse session settings
151153
kwargs
152154
Client specific keyword arguments
153155
@@ -158,6 +160,10 @@ def do_connect(
158160
>>> client
159161
<ibis.clickhouse.client.ClickhouseClient object at 0x...>
160162
"""
163+
if settings is None:
164+
settings = {}
165+
settings.setdefault("session_timezone", "UTC")
166+
161167
self.con = cc.get_client(
162168
host=host,
163169
# 8123 is the default http port 443 is https
@@ -170,11 +176,6 @@ def do_connect(
170176
compress=compression,
171177
**kwargs,
172178
)
173-
try:
174-
with closing(self.raw_sql("SET session_timezone = 'UTC'")):
175-
pass
176-
except Exception as e: # noqa: BLE001
177-
warnings.warn(f"Could not set timezone to UTC: {e}", category=UserWarning)
178179
self._temp_views = set()
179180

180181
@property

0 commit comments

Comments
 (0)