Skip to content

Commit 442c4a6

Browse files
authored
Fix: make jinja-based model rendering more lenient (#5300)
1 parent 5ade723 commit 442c4a6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sqlmesh/core/renderer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,11 @@ def render(
549549
expressions = [e for e in expressions if not isinstance(e, exp.Semicolon)]
550550

551551
if not expressions:
552+
# We assume that if there are no expressions, then the model contains dynamic Jinja SQL
553+
# and we thus treat it similar to models with adapter calls to match dbt's behavior.
554+
if isinstance(self._expression, d.JinjaQuery):
555+
return None
556+
552557
raise ConfigError(f"Failed to render query at '{self._path}':\n{self._expression}")
553558

554559
if len(expressions) > 1:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
{% if execute %}
3+
{% for dataset, nodes in graph.nodes.values() | selectattr("resource_type", "equalto", "model") | groupby('schema') %}
4+
{% if loop.first %}
5+
SELECT 1 AS c
6+
{% endif %}
7+
{% endfor %}
8+
{% endif %}

0 commit comments

Comments
 (0)