Skip to content

Instantly share code, notes, and snippets.

@drewbanin
Last active October 15, 2017 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewbanin/6b488e032b4a35bd830d8423d88bc119 to your computer and use it in GitHub Desktop.
Save drewbanin/6b488e032b4a35bd830d8423d88bc119 to your computer and use it in GitHub Desktop.
-- Load the results of our statement and select the first column
{%- set states = load_result('states')['data'] | map(attribute=0)-%}
select
*,
-- Loop over each state
{% for state in states | list -%}
case
when state = '{{ state }}' then 1
else 0
end as "is_{{ state }}"
{% if not loop.last %} , {% endif %}
{% endfor %}
from {{ ref('users') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment