Skip to content

Commit

Permalink
chore: unnest
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 5, 2024
1 parent 56f6f46 commit 936873b
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,31 +1648,33 @@ def test_no_accidental_cross_database_table_load(con_create_database):

con.drop_table(table)

allowed_exceptions = (
com.IbisError,
# these exception types are None when the backend dependency that
# defines them is not installed
*filter(
None,
(
ClickHouseDatabaseError,
PySparkAnalysisException,
MySQLProgrammingError,
ExaQueryError,
SnowflakeProgrammingError,
GoogleNotFound,
),
# NOTE: this entire block of exception type munging goes away once we unify
# table-not-found exceptions

# always allowed to raise
always_allowed = (com.IbisError,)

# these exception types are None when the backend dependency that
# defines them is not installed
allowed_when_installed = filter(
None,
(
ClickHouseDatabaseError,
PySparkAnalysisException,
MySQLProgrammingError,
ExaQueryError,
SnowflakeProgrammingError,
GoogleNotFound,
),
# datafusion really needs to get their exception story in order
#
# we only want to allow base Exception when we're testing datafusion
# otherwise any exceptions, including those that are unrelated to the
# problem under test will be considered correctly raising
*((Exception,) * (con.name == "datafusion")),
)

# we only want to allow base Exception when we're testing datafusion
# otherwise any exceptions, including those that are unrelated to the
# problem under test will be considered correctly raising
datafusion_only = (Exception,) * (con.name == "datafusion")

# Now attempting to load same table name without specifying db should fail
with pytest.raises(allowed_exceptions):
with pytest.raises((*always_allowed, *allowed_when_installed, *datafusion_only)):
t = con.table(table)

# But can load if specify other db
Expand Down

0 comments on commit 936873b

Please sign in to comment.