QuestionQ44
VerifiedYou have written the following new agg_completed_tasks dbt model:
with tasks as (
select * from \{\{ ref('stg_tasks') \}\}
)
select user_id, \{% for task in tasks %\}
sum(
case when task_name = '\{\{ task \}\}' and state = 'completed'
then 1
else 0
end
) as \{\{ task \}\}_completed
\{% endfor %\}
from tasks group by 1
The dbt model compiles into:
with tasks as (
select * from analytics.dbt_user.stg_tasks
)
select user_id, from tasks group by 1
The case when statement did not appear in the compiled SQL. Why?
Community Discussion