Skip to content

Commit d66d0b8

Browse files
committed
Fix: make jinja-based model rendering more lenient
1 parent a3e7bda commit d66d0b8

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
@@ -542,6 +542,11 @@ def render(
542542
expressions = [e for e in expressions if not isinstance(e, exp.Semicolon)]
543543

544544
if not expressions:
545+
# We assume that if there are no expressions, then the model contains dynamic Jinja SQL
546+
# and we thus treat it similar to models with adapter calls to match dbt's behavior.
547+
if isinstance(self._expression, d.JinjaQuery):
548+
return None
549+
545550
raise ConfigError(f"Failed to render query at '{self._path}':\n{self._expression}")
546551

547552
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)