Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## dbt-databricks 1.13.1 (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.13.0 (Oct 29, 2026)

### Features
Expand Down
10 changes: 5 additions & 5 deletions dbt/adapters/databricks/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,11 +901,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]
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,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
Expand Down
Loading