Skip to content

Commit 7fdcfe8

Browse files
authored
test: regression test for --empty with dbt_utils.union_relations (#807) (#1426)
## Summary Regression test locking in #903's fix for #807: `dbt run --empty` on a model using `dbt_utils.union_relations` no longer fails with `PARSE_SYNTAX_ERROR` from `DESCRIBE TABLE (select * from ... limit 0)`. ## Test plan - [x] Passes against live cluster
1 parent 323cc2d commit 7fdcfe8

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/functional/adapter/empty/test_empty.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import pytest
12
from dbt.tests.adapter.empty.test_empty import BaseTestEmpty, BaseTestEmptyInlineSourceRef
3+
from dbt.tests.util import run_dbt
24

35

46
class TestDatabricksEmpty(BaseTestEmpty):
@@ -7,3 +9,35 @@ class TestDatabricksEmpty(BaseTestEmpty):
79

810
class TestDatabricksEmptyInlineSourceRef(BaseTestEmptyInlineSourceRef):
911
pass
12+
13+
14+
_my_model_sql = "select 1 as id"
15+
16+
_my_model_unioned_sql = """
17+
with unioned as (
18+
{{ dbt_utils.union_relations(relations=[ref("my_model")]) }}
19+
)
20+
select * from unioned
21+
"""
22+
23+
24+
class TestDatabricksEmptyWithUnionRelations:
25+
"""`--empty` must not break dbt_utils.union_relations introspection."""
26+
27+
@pytest.fixture(scope="class")
28+
def models(self):
29+
return {
30+
"my_model.sql": _my_model_sql,
31+
"my_model_unioned.sql": _my_model_unioned_sql,
32+
}
33+
34+
@pytest.fixture(scope="class")
35+
def packages(self):
36+
return {"packages": [{"package": "dbt-labs/dbt_utils", "version": "1.3.0"}]}
37+
38+
def test_union_relations_succeeds(self, project):
39+
run_dbt(["deps"])
40+
results = run_dbt(["run", "-s", "+my_model_unioned", "--empty"])
41+
assert len(results) == 2
42+
for r in results:
43+
assert r.status == "success", f"{r.node.name} failed: {r.message}"

0 commit comments

Comments
 (0)