New Year Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: simple70

dbt Labs dbt Analytics Engineering Certification Exam dbt-Analytics-Engineering Question # 5 Topic 1 Discussion

dbt Labs dbt Analytics Engineering Certification Exam dbt-Analytics-Engineering Question # 5 Topic 1 Discussion

dbt-Analytics-Engineering Exam Topic 1 Question 5 Discussion:
Question #: 5
Topic #: 1

You have written this 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 to:

with tasks as (

select * from analytics.dbt_user.stg_tasks

)

select

user_id,

from tasks

group by 1

The case when statement did not populate in the compiled SQL. Why?


A.

Because there is not a {% if not loop.last %}{% endif %} to compile a valid case when statement.


B.

Because the Jinja for-loop should be written with {{ }} instead of {% %}.


C.

Because there is no {% set tasks %} statement in the model defining the tasks variable.


D.

Because there is not a task_name column in stg_tasks.


Get Premium dbt-Analytics-Engineering Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.