Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(databricks): bind connected catalog to SQL warehouse session (#20188)

h3n4l695d5341ac8c
diff --git a/backend/plugin/db/databricks/databricks.go b/backend/plugin/db/databricks/databricks.go
index d361141136..909f3dffe3 100644
--- a/backend/plugin/db/databricks/databricks.go
+++ b/backend/plugin/db/databricks/databricks.go
@@ -159,9 +159,13 @@ func (d *Driver) Execute(ctx context.Context, statement string, _ db.ExecuteOpti
// Execute SQL statement synchronously and return row data or error.
func (d *Driver) execStatementSync(ctx context.Context, statement string) ([][]string, []dbsql.ColumnInfo, error) {
+ // Bind the connected Bytebase database (= Unity Catalog) to the
+ // session, so unqualified `schema.table` references resolve like in
+ // other RDBMSes. Equivalent to issuing `USE CATALOG <name>` first.
resp, err := d.Client.StatementExecution.ExecuteAndWait(ctx, dbsql.ExecuteStatementRequest{
Statement: statement,
WarehouseId: d.WarehouseID,
+ Catalog: d.curCatalog,
})
if err != nil {
return nil, nil, err