-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: implement builtin date spine macro #2990
Conversation
Sung Won Chung seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
I signed the CLA with the correct github username. Commits under my personal name is likely due to using my personal laptop for commits. For all purposes, both commit signatures are the same person. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sick how simple the implementation is now 🚀
The PR looks good, just a few comments to consider re: docs and test refactoring.
Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
The goal of this PR is to bring a lot of UX familiarity from dbt-utils into SQLMesh native macros similar to the deduplicate macro I just contributed.
dbt-utils version of this macro: https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/date_spine.sql
This renders to SQL to generate a date spine table. It's typically used to join in unique, hard-coded, date ranges to join with other tables/views so people don't have to constantly adjust date ranges in
where
clauses everywhere.Design Highlights
generate_date_array
transpiling and behaving very differently across query engines. Huge thanks to @georgesittas to making this PR way easier for me. He's a real one.25.11.2.dev1
Differences from dbt-utils' version
start_date
(if it is aligned to the datepart), AND it will include theend_date
@date_spine('quarter', '2022-01-01', '2024-12-16')
generate_series
-like sql functions to be faster and cheaper for the majority of query engines. If those functions don't exist for a particular engine (ex: redshift), recursion will be used.Other examples of ad hoc queries working across engines:
BigQuery
Redshift
Snowflake