Error working through "union_tables_by_prefix macro" example in the Jinja, Macros, Packages training class

The error is: Database Error in rpc request (from remote system.sql) 001003 (42000): SQL compilation error: syntax error line 1 at position 0 unexpected ‘limit’.

Database is Snowflake. I’m not able to provide compiled code as I cannot get the code to compile due to this error

Code from the training video is:

{% macro template_example() %}

    {% set query %}
        select true as bool
    {% endset %}

{% if execute %}
    {% set results = run_query(query).columns[0].values()[0] %}
    {{ log("SQL results " ~ results, info=True) }}

    select {{ results }} as is_real
    from a_real_table

{% endif %}

{% end macro %}

Any help is greatly appreciated.

Thanks.

I believe I have answered my own question. This error occurs when I try to compile macros, which I now see is not necessary. When I run them with dbt run-operation I have no trouble. I’m new to this platform and still learning…

1 Like

Good solve @jjage5729! One other solution for the future - if you need to preview the behaviour of a macro, you can open a new Scratchpad and call it from there:

Excellent. Thank you for the help and I love your tool. Thi is a really cool development environment.

1 Like

Thank you for noting this @jjage5729!! I’m going to make a note for our team to add a note to the course about this to clarify for future learners. :tada:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.