Skip to content
Merged
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
5 changes: 4 additions & 1 deletion sqlmesh/core/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,10 @@ def _props_sql(self: Generator, expressions: t.List[exp.Expression]) -> str:
size = len(expressions)

for i, prop in enumerate(expressions):
sql = self.indent(f"{prop.name} {self.sql(prop, 'value')}")
if isinstance(prop, MacroFunc):
sql = self.indent(self.sql(prop, comment=False))
else:
sql = self.indent(f"{prop.name} {self.sql(prop, 'value')}")

if i < size - 1:
sql += ","
Expand Down
8 changes: 6 additions & 2 deletions tests/core/test_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_format_model_expressions():
a,
(b, c) as d,
), -- c
@macro_prop_with_comment(proper := 'foo'), -- k
audits [
not_null(columns=[
foo_id,
Expand Down Expand Up @@ -91,6 +92,7 @@ def test_format_model_expressions():
name a.b, /* a */
kind FULL, /* b */
references (a, (b, c) AS d), /* c */
@macro_prop_with_comment(proper := 'foo'), /* k */
audits ARRAY(
NOT_NULL(
columns = ARRAY(
Expand Down Expand Up @@ -269,7 +271,7 @@ def test_format_body_macros():
format_model_expressions(
parse(
"""
Model ( name foo );
Model ( name foo , @macro_dialect(), @properties_macro(prop_1 := 'max', prop_2 := 33));
@WITH(TRUE) x AS (SELECT 1)
SELECT col::int
FROM foo
Expand All @@ -281,7 +283,9 @@ def test_format_body_macros():
)
)
== """MODEL (
name foo
name foo,
@macro_dialect(),
@properties_macro(prop_1 := 'max', prop_2 := 33)
);

@WITH(TRUE) x AS (
Expand Down