Skip to content

Commit

Permalink
Fix: Parsing of session properties when only one key-value pair is pr…
Browse files Browse the repository at this point in the history
…ovided (TobikoData#2610)
  • Loading branch information
izeigerman authored May 14, 2024
1 parent f0d7bda commit 404c68e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sqlmesh/core/model/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,8 @@ def _resolve_session_properties(
if isinstance(provided, dict):
session_properties = {k: exp.Literal.string(k).eq(v) for k, v in provided.items()}
elif provided:
if isinstance(provided, exp.Paren):
provided = exp.Tuple(expressions=[provided.this])
session_properties = {expr.this.name: expr for expr in provided}
else:
session_properties = {}
Expand Down
18 changes: 18 additions & 0 deletions tests/core/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2833,6 +2833,24 @@ def test_model_session_properties(sushi_context):
"unquoted_identifier": exp.column("unquoted_identifier", quoted=False),
}

model = load_sql_based_model(
d.parse(
"""
MODEL (
name test_schema.test_model,
session_properties (
'warehouse' = 'test_warehouse'
)
);
SELECT a FROM tbl;
""",
default_dialect="snowflake",
)
)
assert model.session_properties == {
"warehouse": "test_warehouse",
}


def test_model_jinja_macro_rendering():
expressions = d.parse(
Expand Down

0 comments on commit 404c68e

Please sign in to comment.