Skip to content

Commit 065516d

Browse files
authored
Fix: handle Paren in depends_on validator (#3243)
1 parent 81f2a65 commit 065516d

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

sqlmesh/core/model/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def depends_on(cls: t.Type, v: t.Any, values: t.Dict[str, t.Any]) -> t.Optional[
9393
dialect = values.get("dialect")
9494
default_catalog = values.get("default_catalog")
9595

96+
if isinstance(v, exp.Paren):
97+
v = v.unnest()
98+
9699
if isinstance(v, (exp.Array, exp.Tuple)):
97100
return {
98101
normalize_model_name(

tests/core/test_model.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,17 +2661,17 @@ def test_missing_schema_warnings():
26612661

26622662

26632663
def test_user_provided_depends_on():
2664-
expressions = d.parse(
2665-
"""
2666-
MODEL (name db.table, depends_on [table_b]);
2667-
2668-
SELECT a FROM table_a
2669-
"""
2670-
)
2664+
for l_delim, r_delim in (("(", ")"), ("[", "]")):
2665+
expressions = d.parse(
2666+
f"""
2667+
MODEL (name db.table, depends_on {l_delim}table_b{r_delim});
26712668
2672-
model = load_sql_based_model(expressions)
2669+
SELECT a FROM table_a
2670+
"""
2671+
)
26732672

2674-
assert model.depends_on == {'"table_a"', '"table_b"'}
2673+
model = load_sql_based_model(expressions)
2674+
assert model.depends_on == {'"table_a"', '"table_b"'}, f"Delimiters {l_delim}, {r_delim}"
26752675

26762676

26772677
def test_check_schema_mapping_when_rendering_at_runtime(assert_exp_eq):

0 commit comments

Comments
 (0)