Why does Jinja parse the commented-out macros in SQL queries?

I tried to comment and keep my old macro code, but dbt failed to compile the macro.
The problem is that Jinja parses the commented-out lines and finds {{}} in the query so shows an error message.

{% macro markup(column1, column2) %}
({{column1}} - {{column2}})/{{column2}}
{% endmacro %}


/*
{% macro markup(x, y) %}
({{x}} - {{y}})/{{y}}
{% endmacro %}
*/

The same problem happens if I comment out the macro in the main SQL query and don’t keep any commented code in the macro.sql file.

select *
--, {{ markup('ordersellingprice', 'ordercostprice') }} as markup
from {{ ref('raw_orders') }} as o

Jinja must not parse the commented lines.

Jinja context should be commented out with {# … #}

3 Likes