0
0
dbtdata~10 mins

dbt-date for date spine - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select the date column from the date spine model.

dbt
SELECT [1] FROM {{ ref('date_spine') }}
Drag options to blanks, or click blank then click option'
Auser_id
Bdate
Ccreated_at
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting a column that does not exist in the date spine model.
Using a column related to users instead of dates.
2fill in blank
medium

Complete the code to generate a date spine from 2023-01-01 to 2023-01-10 using dbt-date.

dbt
SELECT * FROM {{ dbt_utils.date_spine('day', '2023-01-01', [1]) }}
Drag options to blanks, or click blank then click option'
A'2023-01-10'
B'2023-01-05'
C'2023-01-15'
D'2023-01-20'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a date outside the desired range.
Confusing start and end dates.
3fill in blank
hard

Fix the error in the code to correctly generate a date spine for months from 2023-01-01 to 2023-03-01.

dbt
SELECT * FROM {{ dbt_utils.date_spine([1], '2023-01-01', '2023-03-01') }}
Drag options to blanks, or click blank then click option'
A'year'
B'day'
C'month'
D'week'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'day' instead of 'month' for monthly spine.
Using an invalid grain string.
4fill in blank
hard

Fill both blanks to create a date spine for weeks from 2023-01-01 to 2023-02-01 and select the date column.

dbt
WITH spine AS (
  SELECT * FROM {{ dbt_utils.date_spine([1], [2], '2023-02-01') }}
)
SELECT date FROM spine
Drag options to blanks, or click blank then click option'
A'week'
B'2023-01-01'
C'2023-01-15'
D'2023-01-31'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping start and end dates.
Using wrong grain like 'day' for weekly spine.
5fill in blank
hard

Fill all three blanks to create a date spine for days from 2023-01-01 to 2023-01-07, select the date, and filter dates after 2023-01-03.

dbt
WITH spine AS (
  SELECT * FROM {{ dbt_utils.date_spine([1], [2], [3]) }}
)
SELECT date FROM spine WHERE date > '2023-01-03'
Drag options to blanks, or click blank then click option'
A'day'
B'2023-01-01'
C'2023-01-07'
D'2023-01-05'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect date range.
Using wrong grain like 'month' for daily spine.