Skip to content

Commit

Permalink
test(polars): add test for cleaning up the SQL context when a table i…
Browse files Browse the repository at this point in the history
…s dropped
  • Loading branch information
cpcloud committed Aug 26, 2024
1 parent 9da3c9f commit 91141cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions ibis/backends/polars/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import annotations

import pytest

from ibis.backends.tests.errors import PolarsSQLInterfaceError
from ibis.util import gen_name


def test_cannot_run_sql_after_drop(con):
t = con.table("functional_alltypes")
n = t.count().execute()

name = gen_name("polars_dot_sql")
con.create_table(name, t)

sql = f"SELECT COUNT(*) FROM {name}"

expr = con.sql(sql)
result = expr.execute()
assert result.iat[0, 0] == n

con.drop_table(name)
with pytest.raises(PolarsSQLInterfaceError):
con.sql(sql)
3 changes: 2 additions & 1 deletion ibis/backends/tests/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@
from polars.exceptions import InvalidOperationError as PolarsInvalidOperationError
from polars.exceptions import PanicException as PolarsPanicException
from polars.exceptions import SchemaError as PolarsSchemaError
from polars.exceptions import SQLInterfaceError as PolarsSQLInterfaceError
except ImportError:
PolarsComputeError = PolarsPanicException = PolarsInvalidOperationError = (
PolarsSchemaError
) = PolarsColumnNotFoundError = None
) = PolarsColumnNotFoundError = PolarsSQLInterfaceError = None

try:
from pyarrow import ArrowInvalid, ArrowNotImplementedError
Expand Down

0 comments on commit 91141cf

Please sign in to comment.