Last active
October 15, 2017 01:02
-
-
Save drewbanin/6b488e032b4a35bd830d8423d88bc119 to your computer and use it in GitHub Desktop.
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
-- 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