Skip to content

Chore!: deprecate support for mixing Jinja & SQLMesh macros#5158

Closed
georgesittas wants to merge 1 commit intomainfrom
jo/deprecate_mixing_of_jinja_and_sqlmesh_macros
Closed

Chore!: deprecate support for mixing Jinja & SQLMesh macros#5158
georgesittas wants to merge 1 commit intomainfrom
jo/deprecate_mixing_of_jinja_and_sqlmesh_macros

Conversation

@georgesittas
Copy link
Contributor

Mixing jinja and sqlmesh macros is discouraged today and it probably doesn't quite work in many cases. This PR deprecates any support that existed for mixing the two systems, in favour of reducing the overhead involved in rendering jinja-based queries (e.g., that come from dbt projects). Now, sqlmesh macros are only rendered for non-jinja-based models.

@georgesittas georgesittas requested review from a team and izeigerman August 14, 2025 16:25
@georgesittas georgesittas force-pushed the jo/deprecate_mixing_of_jinja_and_sqlmesh_macros branch from 3c24421 to 51c51c1 Compare August 14, 2025 16:25
@georgesittas
Copy link
Contributor Author

Discussed more and for now we'll avoid doing this after all, as there's a risk of breaking projects that rely on builtin datetime sqlmesh macro variables.

For future reference, an example like this doesn't work today, because we don't have an AST at load time to extract the referenced variables and populate the python_env:

MODEL (
  name test_model,
  kind FULL
);

JINJA_QUERY_BEGIN;
SELECT 1 AS
   c1, @foo AS c2
JINJA_END;

However, if instead of @foo we had @start_date, that'd work because it's a builtin. Users may be relying on this behavior, which is exactly why we're not moving forward with this now.

@georgesittas georgesittas deleted the jo/deprecate_mixing_of_jinja_and_sqlmesh_macros branch August 14, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant