# Error working through "union\_tables\_by\_prefix macro" example in the Jinja, Macros, Packages training class

**URL:** <https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102>\
**Category:** Help\
**Tags:** jinja, snowflake\
**Created:** [January 15, 2023, 6:06pm UTC](https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102 "2023-01-15T18:06:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjage5729](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jjage5729/32/1627_2.png) [@jjage5729](https://discourse.getdbt.com/u/jjage5729)\
**Post date:** [January 15, 2023, 6:06pm UTC](https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102/1 "2023-01-15T18:06:04Z")

</div>

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:

```auto
{% 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.

---

<div class="post-metadata">

**Author:** ![jjage5729](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jjage5729/32/1627_2.png) [@jjage5729](https://discourse.getdbt.com/u/jjage5729)\
**Post date:** [January 16, 2023, 7:50pm UTC](https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102/2 "2023-01-16T19:50:49Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [January 17, 2023, 4:37am UTC](https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102/3 "2023-01-17T04:37:11Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/c/c45f030d74191cb005fb439c55529f7ad33d08d8.png)

---

<div class="post-metadata">

**Author:** ![jjage5729](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jjage5729/32/1627_2.png) [@jjage5729](https://discourse.getdbt.com/u/jjage5729)\
**Post date:** [January 17, 2023, 7:39pm UTC](https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102/4 "2023-01-17T19:39:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![coap](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/coap/32/1645_2.png) [@coap](https://discourse.getdbt.com/u/coap)\
**Post date:** [January 17, 2023, 8:52pm UTC](https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102/5 "2023-01-17T20:52:12Z")

</div>

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. 🎉

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [January 24, 2023, 8:52pm UTC](https://discourse.getdbt.com/t/error-working-through-union-tables-by-prefix-macro-example-in-the-jinja-macros-packages-training-class/6102/6 "2023-01-24T20:52:57Z")

</div>

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