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 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" )