From 47fe63c00902fe7924547c0501eb20303f0a46ef Mon Sep 17 00:00:00 2001 From: Emre Kabalci <9528391+emrekabalcii@users.noreply.github.com> Date: Tue, 27 Oct 2026 11:44:50 +0300 Subject: [PATCH 1/2] fix: skip forcing absent catalog metadata columns to Text Rows built by _get_columns_for_catalog omit None-valued keys, so comment, table_owner and table_comment are often missing from the table. Forcing them in build_type_tester made agate emit one RuntimeWarning per absent column per schema during dbt docs generate. Only force the columns that are present. Signed-off-by: Emre Kabalci <9528391+emrekabalcii@users.noreply.github.com> --- dbt/adapters/databricks/impl.py | 10 +++++----- tests/unit/test_adapter.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py index 7de5e4070..f692359fb 100644 --- a/dbt/adapters/databricks/impl.py +++ b/dbt/adapters/databricks/impl.py @@ -883,11 +883,11 @@ def _get_schema_for_catalog(self, catalog: str, schema: str, identifier: str) -> ) for relation, information in self._list_relations_with_information(schema_relation): columns.extend(self._get_columns_for_catalog(relation, information)) - # An empty input produces a 0-column table; force-typing absent columns - # would emit one RuntimeWarning per name. Skip the override in that case. - column_types = ( - build_type_tester(self.CATALOG_TEXT_ONLY_COLUMNS) if columns else DEFAULT_TYPE_TESTER - ) + # Rows omit None-valued keys, so a forced column can be absent from the table, and + # agate emits one RuntimeWarning per absent name. Only force the columns present. + present = {key for row in columns for key in row} + text_only = [col for col in self.CATALOG_TEXT_ONLY_COLUMNS if col in present] + column_types = build_type_tester(text_only) if text_only else DEFAULT_TYPE_TESTER return Table.from_object(columns, column_types=column_types) def _get_columns_for_catalog( # type: ignore[override] diff --git a/tests/unit/test_adapter.py b/tests/unit/test_adapter.py index a800dbe9c..3e5df0810 100644 --- a/tests/unit/test_adapter.py +++ b/tests/unit/test_adapter.py @@ -564,6 +564,28 @@ def test_get_schema_for_catalog__no_columns_emits_no_warnings(self, _): table = adapter._get_schema_for_catalog("database", "schema", "name") assert len(table.rows) == 0 + @patch("dbt.adapters.databricks.api_client.DatabricksApiClient") + def test_get_schema_for_catalog__omitted_none_columns_emit_no_warnings(self, _): + # `to_column_dict` omits None-valued keys, so a schema with no owner or comments + # yields rows without `table_owner`, `table_comment` and `comment`. + row = { + k: v + for k, v in _catalog_row("12345").items() + if k not in ("table_owner", "table_comment", "comment") + } + with patch.object(DatabricksAdapter, "_list_relations_with_information") as list_info: + list_info.return_value = [(Mock(), "info")] + with patch.object(DatabricksAdapter, "_get_columns_for_catalog") as get_columns: + get_columns.return_value = [row] + adapter = DatabricksAdapter(Mock(flags={}), get_context("spawn")) + with warnings.catch_warnings(): + warnings.simplefilter("error", RuntimeWarning) + table = adapter._get_schema_for_catalog("cat", "schema", "name") + + assert "comment" not in table.column_names + types = dict(zip(table.column_names, table.column_types)) + assert isinstance(types["column_name"], agate.data_types.text.Text) + def test_simple_catalog_relation(self): self.maxDiff = None rel_type = DatabricksRelation.get_relation_type.Table From 524d378464d44660eeeb6d01a5a12aa6441303b0 Mon Sep 17 00:00:00 2001 From: Emre Kabalci <9528391+emrekabalcii@users.noreply.github.com> Date: Tue, 27 Oct 2026 11:47:03 +0300 Subject: [PATCH 2/2] chore: add changelog entry for catalog warning fix Signed-off-by: Emre Kabalci <9528391+emrekabalcii@users.noreply.github.com> --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 380f0241c..200e64849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## dbt-databricks 1.12.9 (TBD) + +### Fixes + +- Stop `dbt docs generate` from emitting a `RuntimeWarning` per schema for catalog metadata columns that are absent from the results (thanks @emrekabalcii!) ([#1749](https://github.com/databricks/dbt-databricks/pull/1749) resolves [#1748](https://github.com/databricks/dbt-databricks/issues/1748)) + ## dbt-databricks 1.12.8 (Oct 24, 2026) ### Fixes