3
3
import ast
4
4
import atexit
5
5
import glob
6
- import warnings
7
6
from contextlib import closing , suppress
8
7
from functools import partial
9
8
from typing import TYPE_CHECKING , Any , Literal
@@ -123,6 +122,7 @@ def do_connect(
123
122
client_name : str = "ibis" ,
124
123
secure : bool | None = None ,
125
124
compression : str | bool = True ,
125
+ settings : Mapping [str , Any ] | None = None ,
126
126
** kwargs : Any ,
127
127
):
128
128
"""Create a ClickHouse client for use with Ibis.
@@ -148,6 +148,8 @@ def do_connect(
148
148
The kind of compression to use for requests. See
149
149
https://clickhouse.com/docs/en/integrations/python#compression for
150
150
more information.
151
+ settings
152
+ ClickHouse session settings
151
153
kwargs
152
154
Client specific keyword arguments
153
155
@@ -158,6 +160,10 @@ def do_connect(
158
160
>>> client
159
161
<ibis.clickhouse.client.ClickhouseClient object at 0x...>
160
162
"""
163
+ if settings is None :
164
+ settings = {}
165
+ settings .setdefault ("session_timezone" , "UTC" )
166
+
161
167
self .con = cc .get_client (
162
168
host = host ,
163
169
# 8123 is the default http port 443 is https
@@ -170,11 +176,6 @@ def do_connect(
170
176
compress = compression ,
171
177
** kwargs ,
172
178
)
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 )
178
179
self ._temp_views = set ()
179
180
180
181
@property
0 commit comments