Skip to content

Commit f211d91

Browse files
committed
Merge branch 'main' into 1.10.latest
2 parents f5b36a2 + 8f2884c commit f211d91

File tree

4 files changed

+95
-3
lines changed

4 files changed

+95
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## dbt-databricks 1.10.7 (TBD)
1+
## dbt-databricks 1.10.8 (TBD)
2+
3+
## dbt-databricks 1.10.7 (July 31, 2025)
4+
5+
### Fixes
6+
- Do not use `DESCRIBE TABLE EXTENDED .. AS JSON` for STs when DBR version < 17.1. Do not use at all for MVs (not yet supported)
27

38
## dbt-databricks 1.10.6 (July 30, 2025)
49

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "1.10.6"
1+
version = "1.10.7"

dbt/adapters/databricks/impl.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,15 @@ def get_columns_in_relation( # type: ignore[override]
481481
self, relation: DatabricksRelation
482482
) -> list[DatabricksColumn]:
483483
# Use legacy macros for hive metastore or DBR versions older than 16.2
484-
use_legacy_logic = relation.is_hive_metastore() or self.compare_dbr_version(16, 2) < 0
484+
use_legacy_logic = (
485+
relation.is_hive_metastore()
486+
or self.compare_dbr_version(16, 2) < 0
487+
or relation.type == DatabricksRelationType.MaterializedView
488+
or (
489+
relation.type == DatabricksRelationType.StreamingTable
490+
and self.compare_dbr_version(17, 1) < 0
491+
)
492+
)
485493
return self.get_column_behavior.get_columns_in_relation(self, relation, use_legacy_logic)
486494

487495
def _get_updated_relation(

tests/unit/test_adapter.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,3 +1094,82 @@ def test_get_columns_new_logic(self, mock_get_columns, adapter, unity_relation):
10941094
assert result[0].column == "col1"
10951095
assert result[0].dtype == "string"
10961096
assert result[0].comment == "comment1"
1097+
1098+
@patch(
1099+
"dbt.adapters.databricks.behaviors.columns.GetColumnsByDescribe._get_columns_with_comments"
1100+
)
1101+
def test_get_columns_streaming_table_legacy_logic(
1102+
self, mock_get_columns, adapter, unity_relation
1103+
):
1104+
streaming_relation = DatabricksRelation.create(
1105+
database=unity_relation.database,
1106+
schema=unity_relation.schema,
1107+
identifier=unity_relation.identifier,
1108+
type=DatabricksRelation.StreamingTable,
1109+
)
1110+
# Return value less than 0 means version is older than 17.1
1111+
with patch.object(adapter, "compare_dbr_version", return_value=-1):
1112+
mock_get_columns.return_value = [
1113+
{"col_name": "stream_col", "data_type": "int", "comment": "streaming col"},
1114+
]
1115+
result = adapter.get_columns_in_relation(streaming_relation)
1116+
mock_get_columns.assert_called_with(adapter, streaming_relation, "get_columns_comments")
1117+
assert len(result) == 1
1118+
assert result[0].column == "stream_col"
1119+
assert result[0].dtype == "int"
1120+
assert result[0].comment == "streaming col"
1121+
1122+
@patch(
1123+
"dbt.adapters.databricks.behaviors.columns.GetColumnsByDescribe._get_columns_with_comments"
1124+
)
1125+
def test_get_columns_streaming_table_new_logic(self, mock_get_columns, adapter, unity_relation):
1126+
streaming_relation = DatabricksRelation.create(
1127+
database=unity_relation.database,
1128+
schema=unity_relation.schema,
1129+
identifier=unity_relation.identifier,
1130+
type=DatabricksRelation.StreamingTable,
1131+
)
1132+
# Return value 0 means version is 17.1
1133+
with patch.object(adapter, "compare_dbr_version", return_value=0):
1134+
json_data = """
1135+
{
1136+
"columns": [
1137+
{
1138+
"name": "stream_col",
1139+
"type": {"name": "int"},
1140+
"comment": "streaming col"
1141+
}
1142+
]
1143+
}
1144+
"""
1145+
mock_get_columns.return_value = [{"json_metadata": json_data}]
1146+
result = adapter.get_columns_in_relation(streaming_relation)
1147+
mock_get_columns.assert_called_with(
1148+
adapter, streaming_relation, "get_columns_comments_as_json"
1149+
)
1150+
assert len(result) == 1
1151+
assert result[0].column == "stream_col"
1152+
assert result[0].dtype == "int"
1153+
assert result[0].comment == "streaming col"
1154+
1155+
@patch(
1156+
"dbt.adapters.databricks.behaviors.columns.GetColumnsByDescribe._get_columns_with_comments"
1157+
)
1158+
def test_get_columns_materialized_view(self, mock_get_columns, adapter, unity_relation):
1159+
mv_relation = DatabricksRelation.create(
1160+
database=unity_relation.database,
1161+
schema=unity_relation.schema,
1162+
identifier=unity_relation.identifier,
1163+
type=DatabricksRelation.MaterializedView,
1164+
)
1165+
# For MVs, always use legacy logic, regardless of DBR version
1166+
with patch.object(adapter, "compare_dbr_version", return_value=1):
1167+
mock_get_columns.return_value = [
1168+
{"col_name": "mv_col", "data_type": "string", "comment": "mv col"},
1169+
]
1170+
result = adapter.get_columns_in_relation(mv_relation)
1171+
mock_get_columns.assert_called_with(adapter, mv_relation, "get_columns_comments")
1172+
assert len(result) == 1
1173+
assert result[0].column == "mv_col"
1174+
assert result[0].dtype == "string"
1175+
assert result[0].comment == "mv col"

0 commit comments

Comments
 (0)