Skip to content

Create dim dates#37

Merged
rosie-t merged 4 commits into
mainfrom
create_dim_dates
Apr 17, 2026
Merged

Create dim dates#37
rosie-t merged 4 commits into
mainfrom
create_dim_dates

Conversation

@rosie-t
Copy link
Copy Markdown
Collaborator

@rosie-t rosie-t commented Apr 13, 2026

Linked to this ticket

Creating a dim_date table with one row per day. This table isn't macro-dependent (as it was previously.
Calendar attributes are calculated using SQL and a weekend boolean value is added.
The idea is that this dim_table can be joined where time analysis is needed.

Tests are also added and pass.

Copy link
Copy Markdown
Collaborator

@RJO23 RJO23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@harjeetkalsi harjeetkalsi self-assigned this Apr 13, 2026
@harjeetkalsi harjeetkalsi self-requested a review April 13, 2026 14:27
@harjeetkalsi harjeetkalsi removed their assignment Apr 13, 2026
Comment thread models/marts/dim_date.sql Outdated
extract(dayofyear from date_day) as day_of_year,

## Week information ##

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good overall. One thing I’d flag is that we are mixing ISO week logic with calendar year logic here.

week_of_year uses extract(isoweek ...), but year_number uses the calendar year. Around year boundaries that can produce confusing combinations, for example ISO week 1 paired with the previous calendar year, or vice versa.

I think we should either add an iso_year field to keep the week logic consistent, or switch week_of_year to a non-ISO definition if we want this dimension to stay purely calendar-based.

Comment thread models/marts/dim_date.sql
Comment thread models/marts/dim_date.sql
Comment thread models/marts/dim_date.yml
Copy link
Copy Markdown
Collaborator

@harjeetkalsi harjeetkalsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition overall. The model is clean and useful, and the core calendar fields look good.

The main thing I’d like us to address before merging is the week logic. We currently use isoweek for week_of_year, but calendar year for year_number, which can give confusing results around year boundaries. I think we should either add iso_year or make the week definition fully non-ISO for consistency.

A couple of smaller follow-ups:

  • worth making the start/end dates configurable via var()
  • optional, but a date_key could be useful if this is going to be a commonly joined dimension

@rosie-t rosie-t requested a review from harjeetkalsi April 15, 2026 15:52
@rosie-t
Copy link
Copy Markdown
Collaborator Author

rosie-t commented Apr 15, 2026

Changes since last PR

  • Added in better ISO logic and renaming of columns
  • Added testing to account for this

Copy link
Copy Markdown
Collaborator

@harjeetkalsi harjeetkalsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really strong PR, well done Rosie!

You’ve taken the feedback on board and implemented the configurable date range cleanly using var(), which makes the model much more flexible across environments (by that I meean: test, dev prod). The use of generate_date_array to build the date spine is also a great choice.

The overall structure of the dim_date model is clear, well organised, and easy to follow, with good coverage across day, ISO week, month, quarter, and year.

Quality of your tests is great too. You’ve gone beyond basic checks and are validating logic and edge cases. The is_weekend test enforces consistency nicely, and the ISO year/week tests are strong as they cover boundary cases too.

You've built something that is reliable, testable, and prod ready.

Happy to approve :)

@rosie-t rosie-t merged commit 41afc31 into main Apr 17, 2026
1 check passed
@rosie-t rosie-t deleted the create_dim_dates branch April 17, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants