Created
April 5, 2022 14:46
-
-
Save StuffbyYuki/c2ed822c87fb9efc037bc569128b8cc1 to your computer and use it in GitHub Desktop.
dbt jinja - store a query result in a variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source website | |
// https://stackoverflow.com/questions/64007239/hi-how-do-we-define-select-statement-as-a-variable-in-dbt | |
{%- call statement('my_statement', fetch_result=True) -%} | |
SELECT my_field FROM my_table | |
{%- endcall -%} | |
{%- set my_var = load_result('my_statement')['data'][0][0] -%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment