From 949a28e46d01550cb19ce2b7e9ecf677941543c7 Mon Sep 17 00:00:00 2001 From: willweld Date: Wed, 20 May 2026 11:22:20 -0700 Subject: [PATCH 1/2] fix: skip DESCRIBE TABLE EXTENDED AS JSON for foreign/federated tables Foreign/federated tables do not support the AS JSON form, causing the adapter to attempt it (and fail) before falling back to plain DESCRIBE TABLE on every code path that calls get_columns_in_relation. Add relation.is_foreign_table to the use_legacy_logic guard, consistent with the existing check in is_describe_as_json_supported(). Signed-off-by: willweld --- dbt/adapters/databricks/impl.py | 1 + tests/unit/test_adapter.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py index 5e67867fa..ef8e64c13 100644 --- a/dbt/adapters/databricks/impl.py +++ b/dbt/adapters/databricks/impl.py @@ -624,6 +624,7 @@ def get_columns_in_relation( # type: ignore[override] # TODO: Replace with streaming table capability check when 17.1 is current version # for SQL warehouses or relation.type == DatabricksRelationType.StreamingTable + or relation.is_foreign_table ) return self.get_column_behavior.get_columns_in_relation(self, relation, use_legacy_logic) diff --git a/tests/unit/test_adapter.py b/tests/unit/test_adapter.py index 0c2b5ca80..47af06523 100644 --- a/tests/unit/test_adapter.py +++ b/tests/unit/test_adapter.py @@ -1268,6 +1268,29 @@ def test_get_columns_materialized_view(self, mock_get_columns, adapter, unity_re assert result[0].dtype == "string" assert result[0].comment == "mv col" + @patch( + "dbt.adapters.databricks.behaviors.columns.GetColumnsByDescribe._get_columns_with_comments" + ) + def test_get_columns_foreign_table_uses_legacy_logic( + self, mock_get_columns, adapter, unity_relation + ): + foreign_relation = DatabricksRelation.create( + database=unity_relation.database, + schema=unity_relation.schema, + identifier=unity_relation.identifier, + type=DatabricksRelationType.Foreign, + ) + # Foreign/federated tables don't support AS JSON — always use legacy logic + with patch.object(adapter, "has_capability", return_value=True): + mock_get_columns.return_value = [ + {"col_name": "federated_col", "data_type": "string", "comment": ""}, + ] + result = adapter.get_columns_in_relation(foreign_relation) + mock_get_columns.assert_called_with(adapter, foreign_relation, "get_columns_comments") + assert len(result) == 1 + assert result[0].column == "federated_col" + assert result[0].dtype == "string" + @patch( "dbt.adapters.databricks.behaviors.columns.GetColumnsByDescribe._get_columns_with_comments" ) From 0b0b5ed7fb60f3e8d74a24da5b4d007201f7d940 Mon Sep 17 00:00:00 2001 From: willweld Date: Wed, 20 May 2026 11:25:26 -0700 Subject: [PATCH 2/2] chore: update CHANGELOG for #1472 Signed-off-by: willweld --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99848374f..8e5f170e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Expose `job_id`, `job_run_id`, and `task_run_id` from the Databricks Jobs `dbt_task` runtime in `adapter_response`, enabling correlation between dbt runs and Databricks workflow executions via `run_results.json` ([#1451](https://github.com/databricks/dbt-databricks/pull/1451) closes [#722](https://github.com/databricks/dbt-databricks/issues/722)) +### Fixes + +- Skip `DESCRIBE TABLE EXTENDED ... AS JSON` for foreign/federated tables in `get_columns_in_relation`, avoiding repeated failures and extra latency on those sources ([#1472](https://github.com/databricks/dbt-databricks/pull/1472)) + ## dbt-databricks 1.12.0 (May 18, 2026) ### Features