Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The date spine model contains a 'date' column representing each date in the range.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a date outside the desired range.
Confusing start and end dates.
✗ Incorrect
The date spine should cover dates up to '2023-01-10' as specified.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'day' instead of 'month' for monthly spine.
Using an invalid grain string.
✗ Incorrect
To generate a monthly date spine, the grain must be 'month'.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping start and end dates.
Using wrong grain like 'day' for weekly spine.
✗ Incorrect
The grain is 'week' and the start date is '2023-01-01' to cover weeks starting from that date.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect date range.
Using wrong grain like 'month' for daily spine.
✗ Incorrect
The grain is 'day', start date '2023-01-01', and end date '2023-01-07' to cover the desired range.