Skip to content

Commit

Permalink
fix: catalog upgrade/downgrade (apache#29780)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored Jul 30, 2024
1 parent 8891f04 commit 525e837
Show file tree
Hide file tree
Showing 4 changed files with 439 additions and 152 deletions.
9 changes: 8 additions & 1 deletion superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@

logger = logging.getLogger()

# When connecting to a database it's hard to catch specific exceptions, since we support
# more than 50 different database drivers. Usually the try/except block will catch the
# generic `Exception` class, which requires a pylint disablee comment. To make it clear
# that we know this is a necessary evil we create an alias, and catch it instead.
GenericDBException = Exception


def convert_inspector_columns(cols: list[SQLAColumnType]) -> list[ResultSetColumnType]:
result_set_columns: list[ResultSetColumnType] = []
Expand Down Expand Up @@ -406,7 +412,8 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
#
# When this is changed to true in a DB engine spec it MUST support the
# `get_default_catalog` and `get_catalog_names` methods. In addition, you MUST write
# a database migration updating any existing schema permissions.
# a database migration updating any existing schema permissions using the helper
# `upgrade_catalog_perms`.
supports_catalog = False

# Can the catalog be changed on a per-query basis?
Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ def get_default_catalog(
cls,
database: Database,
) -> str | None:
with database.get_inspector() as inspector:
return inspector.bind.execute("SELECT current_catalog()").scalar()
with database.get_sqla_engine() as engine:
return engine.execute("SELECT current_catalog()").scalar()

@classmethod
def get_prequeries(
Expand Down
Loading

0 comments on commit 525e837

Please sign in to comment.