0
0
dbtdata~20 mins

dbt-date for date spine - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
dbt-date Date Spine Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of dbt-date date_spine with daily frequency
What is the output of this dbt SQL code that uses dbt-date's date_spine macro to generate dates from 2024-01-01 to 2024-01-05 with daily frequency?
dbt
select * from {{ dbt_date.date_spine(
  datepart='day',
  start_date='2024-01-01',
  end_date='2024-01-05'
)}} order by date_day
A[{'date_day': '2024-01-01'}, {'date_day': '2024-01-02'}, {'date_day': '2024-01-03'}, {'date_day': '2024-01-04'}, {'date_day': '2024-01-05'}]
B[{'date_day': '2024-01-01'}, {'date_day': '2024-01-03'}, {'date_day': '2024-01-05'}]
C[{'date_day': '2024-01-02'}, {'date_day': '2024-01-03'}, {'date_day': '2024-01-04'}]
D[{'date_day': '2024-01-01'}, {'date_day': '2024-01-02'}, {'date_day': '2024-01-04'}, {'date_day': '2024-01-05'}]
Attempts:
2 left
💡 Hint
Think about what daily frequency means for a date range from start to end inclusive.
data_output
intermediate
2:00remaining
Number of weeks generated by dbt-date date_spine
Using dbt-date's date_spine macro with weekly frequency from 2024-01-01 to 2024-02-01, how many rows will the resulting date spine table have?
dbt
select count(*) as week_count from {{ dbt_date.date_spine(
  datepart='week',
  start_date='2024-01-01',
  end_date='2024-02-01'
)}}
A4
B5
C6
D7
Attempts:
2 left
💡 Hint
Count the number of weeks starting from the first week containing 2024-01-01 up to the week containing 2024-02-01.
🔧 Debug
advanced
2:00remaining
Identify the error in dbt-date date_spine usage
What error will this dbt SQL code produce when running the date_spine macro with an invalid datepart 'fortnight'?
dbt
select * from {{ dbt_date.date_spine(
  datepart='fortnight',
  start_date='2024-01-01',
  end_date='2024-01-31'
)}}
ASyntax error: missing comma
BRuntime error: Invalid date format
CEmpty result set with no error
DCompilation error: Unsupported datepart 'fortnight'
Attempts:
2 left
💡 Hint
Check if 'fortnight' is a valid datepart for the macro.
🚀 Application
advanced
2:00remaining
Using dbt-date date_spine to fill missing dates in sales data
You have sales data with some missing dates. Which dbt-date date_spine usage will help create a complete date table from 2024-01-01 to 2024-01-10 to join and fill missing dates?
Aselect * from {{ dbt_date.date_spine(datepart='day', start_date='2024-01-01', end_date='2024-01-10') }}
Bselect * from {{ dbt_date.date_spine(datepart='month', start_date='2024-01-01', end_date='2024-01-10') }}
Cselect * from {{ dbt_date.date_spine(datepart='year', start_date='2024-01-01', end_date='2024-01-10') }}
Dselect * from {{ dbt_date.date_spine(datepart='hour', start_date='2024-01-01', end_date='2024-01-10') }}
Attempts:
2 left
💡 Hint
To fill missing daily sales, you need a daily date spine.
🧠 Conceptual
expert
3:00remaining
Why use dbt-date date_spine for time series analysis?
Which is the best reason to use dbt-date's date_spine macro when preparing data for time series analysis?
ATo filter out weekends and holidays from the dataset
BTo generate a continuous sequence of dates ensuring no gaps in the timeline
CTo aggregate data by random date intervals for sampling
DTo convert string dates into datetime format automatically
Attempts:
2 left
💡 Hint
Think about what a date spine provides for time series data.