Skip to content

Commit a1a882e

Browse files
authored
test: assert databricks_tags applied at create on metric views (#1529)
## Description Strengthens the metric-view materialization test so it verifies, server-side, that `databricks_tags` configured on a `metric_view` model are applied **at create time**. The existing `test_metric_view_with_tags` set `databricks_tags` but asserted only that the `MEASURE()` query ran, so create-time tag application was never verified — the other metric-view tests assert only the *post-update* tags. The test now queries `information_schema.table_tags` after the first build and asserts the configured `team`/`environment` tags are present. Test-only; no runtime change. ## How verified `hatch run pytest tests/functional/adapter/metric_views/test_metric_view_materialization.py::TestMetricViewConfiguration::test_metric_view_with_tags` → passed on `databricks_uc_sql_endpoint`.
1 parent b182e8b commit a1a882e

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

tests/functional/adapter/metric_views/test_metric_view_materialization.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def models(self):
176176
}
177177

178178
def test_metric_view_with_tags(self, project):
179-
"""Test that metric view works with databricks_tags using ALTER VIEW"""
179+
"""databricks_tags configured on a metric view are applied at create time."""
180180
# Run dbt to create the models
181181
results = run_dbt(["run"])
182182
assert len(results) == 2
@@ -204,7 +204,6 @@ def test_metric_view_with_tags(self, project):
204204
fetch="all",
205205
)
206206

207-
# Should have results showing tags were applied without error
208207
assert query_result is not None
209208
assert len(query_result) == 2 # completed and pending statuses
210209

@@ -213,6 +212,21 @@ def test_metric_view_with_tags(self, project):
213212
assert status_data["completed"] == 2
214213
assert status_data["pending"] == 1
215214

215+
# The configured tags land on the view at create time, not just on update
216+
tag_rows = project.run_sql(
217+
f"""
218+
SELECT tag_name, tag_value
219+
FROM {project.database}.information_schema.table_tags
220+
WHERE schema_name = '{project.test_schema}'
221+
AND table_name = 'config_metrics'
222+
ORDER BY tag_name
223+
""",
224+
fetch="all",
225+
)
226+
tags = {row[0]: row[1] for row in tag_rows}
227+
assert tags.get("team") == "analytics"
228+
assert tags.get("environment") == "test"
229+
216230

217231
@pytest.mark.skip_profile("databricks_cluster")
218232
class TestMetricViewBareRef:

0 commit comments

Comments
 (0)