Snowflake’s support for Jinja now includes imports – this means you can modularise your code, and use macros.
Your challenge is to create two scripts:
utils.sql
:
Will contain a macro called power_of_two
that meets the following requirements:
- Accepts a list of numbers
- For each number, returns:
- The original number
- The squared (two the power of two) number
- Unions all
main.sql
:
Will be the file that simply calls the macro – it should use a simple list of `[1, 2, 3, 4]`
If all is correct, you ought to get a result like:
![](https://frostyfriday.org/wp-content/uploads/2025/01/Screenshot-2025-01-03-at-10.14.26.png)
Happy Jinjaing!
This one was quite a hassle, but finally wrangled it to work! Thanks for the challenge!