I want to create a for loop in dbt that loops through two columns of a table in my database and created case when statements using the values in each row of the two columns. Just like this:
{% set locations = {'%United-States%':'United States', '%USA%':'United States'} %}
select
case
{% for feeder, correct in locations.items() %}
when lower(locationname) like {{feeder}} then {{correct}}
{% endfor %}
end as city
from table
I was able to create lists for both feeder and correct, but I am not able to merge them as key-value pairs of a dictionary to loop through it. Any ideas on how should I do this?