Skip to content

Commit

Permalink
fix(clickhouse): use a context manager for execution
Browse files Browse the repository at this point in the history
Ensure we properly disconnect when an error occurs.
  • Loading branch information
cpcloud authored and kszucs committed Mar 31, 2022
1 parent ce37c68 commit a471225
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions ibis/backends/clickhouse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ def raw_sql(
)

ibis.util.log(query)
return self.con.execute(
query,
columnar=True,
with_column_types=True,
external_tables=external_tables_list,
)
with self.con as con:
return con.execute(
query,
columnar=True,
with_column_types=True,
external_tables=external_tables_list,
)

def fetch_from_cursor(self, cursor, schema):
data, _ = cursor
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ addopts = [
filterwarnings = [
# fail on any warnings that are not explicitly matched below
"error",
# pyspark and impala leave sockets open
"ignore:Exception ignored in:",
# Future warning from analytics.py
"ignore:ibis.expr.analytics will be removed in ibis 3.0",
# poetry
"ignore:distutils Version classes are deprecated:DeprecationWarning",
# clickhouse sockets aren't closed by sqlalchemy when running tests in parallel
'ignore:Exception ignored in:',
# older importlib metadata that there's no real point in breaking with
"ignore:SelectableGroups:DeprecationWarning",
# geopandas warning
Expand Down

0 comments on commit a471225

Please sign in to comment.