Skip to content

Commit a471225

Browse files
cpcloudkszucs
authored andcommitted
fix(clickhouse): use a context manager for execution
Ensure we properly disconnect when an error occurs.
1 parent ce37c68 commit a471225

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

ibis/backends/clickhouse/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ def raw_sql(
161161
)
162162

163163
ibis.util.log(query)
164-
return self.con.execute(
165-
query,
166-
columnar=True,
167-
with_column_types=True,
168-
external_tables=external_tables_list,
169-
)
164+
with self.con as con:
165+
return con.execute(
166+
query,
167+
columnar=True,
168+
with_column_types=True,
169+
external_tables=external_tables_list,
170+
)
170171

171172
def fetch_from_cursor(self, cursor, schema):
172173
data, _ = cursor

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ addopts = [
160160
filterwarnings = [
161161
# fail on any warnings that are not explicitly matched below
162162
"error",
163+
# pyspark and impala leave sockets open
164+
"ignore:Exception ignored in:",
163165
# Future warning from analytics.py
164166
"ignore:ibis.expr.analytics will be removed in ibis 3.0",
165167
# poetry
166168
"ignore:distutils Version classes are deprecated:DeprecationWarning",
167-
# clickhouse sockets aren't closed by sqlalchemy when running tests in parallel
168-
'ignore:Exception ignored in:',
169169
# older importlib metadata that there's no real point in breaking with
170170
"ignore:SelectableGroups:DeprecationWarning",
171171
# geopandas warning

0 commit comments

Comments
 (0)