fix(DB update): Gracefully handle querry error during DB update (#33250)

(cherry picked from commit de84a534ac)
This commit is contained in:
Vitor Avila
2025-04-25 15:38:59 -03:00
committed by Michael S. Molina
parent a6895e07b0
commit f8b0632f99
3 changed files with 45 additions and 3 deletions

View File

@@ -437,6 +437,8 @@ class DatabricksNativeEngineSpec(DatabricksDynamicBaseEngineSpec):
"""
Return the default catalog.
It's optionally specified in `connect_args.catalog`. If not:
The default behavior for Databricks is confusing. When Unity Catalog is not
enabled we have (the DB engine spec hasn't been tested with it enabled):
@@ -448,6 +450,10 @@ class DatabricksNativeEngineSpec(DatabricksDynamicBaseEngineSpec):
To handle permissions correctly we use the result of `SHOW CATALOGS` when a
single catalog is returned.
"""
connect_args = cls.get_extra_params(database)["engine_params"]["connect_args"]
if default_catalog := connect_args.get("catalog"):
return default_catalog
with database.get_sqla_engine() as engine:
catalogs = {catalog for (catalog,) in engine.execute("SHOW CATALOGS")}
if len(catalogs) == 1: