Skip to content
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

Add date spine macros to core #8616

Merged
merged 9 commits into from
Sep 25, 2023

Conversation

QMalcolm
Copy link
Contributor

@QMalcolm QMalcolm commented Sep 11, 2023

resolves #8172

Problem

The date_spine macro in dbt-utils is getting used more regularly due to the semantic layer requiring a date spine model to exist. As such we should start including it with dbt-core instead of requiring people to get dbt-utils to do it. Additionally, as #8319 suggests, we want to begin auto generating the metricflow date spine model when semantic objects exist but the required date spine model does not. In that vein, this is a required precursor.

Solution

Move the macros into dbt-core 🚀

Note
We've also created adapter tests. To ensure the macros work in the specific adapters we maintain, I've opened branches on dbt-snowflake, dbt-redshift, and dbt-bigquery to run the tests. And I've run the tests in those branches against this branch of core.

Repo Branch Integration Test Run
dbt-bigquery qmalcolm--date-spine-utils-testing Passing
dbt-snowflake qmalcolm--date-spine-utils-testing Passing
dbt-redshift qmalcolm--date-spine-utils-testing Passing

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@QMalcolm QMalcolm added the Skip Changelog Skips GHA to check for changelog file label Sep 11, 2023
@cla-bot cla-bot bot added the cla:yes label Sep 11, 2023
@codecov
Copy link

codecov bot commented Sep 11, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.01% 🎉

Comparison is base (3cc7044) 86.61% compared to head (b1dbd34) 86.62%.
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8616      +/-   ##
==========================================
+ Coverage   86.61%   86.62%   +0.01%     
==========================================
  Files         175      176       +1     
  Lines       25596    25671      +75     
==========================================
+ Hits        22169    22237      +68     
- Misses       3427     3434       +7     
Flag Coverage Δ
integration 83.44% <ø> (-0.03%) ⬇️
unit 65.14% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 20 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@QMalcolm QMalcolm force-pushed the qmalcolm--8172-add-date-spine-macros-to-core branch from 356e547 to fa8369e Compare September 11, 2023 20:58
The macros added are
- date_spine
- get_intervals_between
- generate_series
- get_powers_of_two

We're adding these to core because they are becoming more prevalently used
with the increase usage in the semantic layer. Basically if you are
using the semantic layer currently, then it is almost a requirement
to use dbt-utils, which is undesireable given the SL is supported directly
in core. The primary focus of this was to just add `date_spine`. However,
because `date_spine` depends on other macros, these other macros were
also moved.
@QMalcolm QMalcolm force-pushed the qmalcolm--8172-add-date-spine-macros-to-core branch 2 times, most recently from 7fa5715 to be7ffb3 Compare September 15, 2023 22:19
@QMalcolm QMalcolm added dbt-docs [dbt feature] documentation site, powered by metadata artifacts user docs [docs.getdbt.com] Needs better documentation and removed dbt-docs [dbt feature] documentation site, powered by metadata artifacts labels Sep 15, 2023
@QMalcolm QMalcolm removed the Skip Changelog Skips GHA to check for changelog file label Sep 22, 2023
@QMalcolm QMalcolm changed the title WIP: Add date spine macros to core Add date spine macros to core Sep 22, 2023
@QMalcolm QMalcolm marked this pull request as ready for review September 22, 2023 21:41
@QMalcolm QMalcolm requested review from a team as code owners September 22, 2023 21:41
@MichelleArk
Copy link
Contributor

Is there a deprecation plan in place for these macros in dbt-utils? If the implementations of the two diverge this could lead to some surprising behaviour - especially if dbt-utils is installed and its date spine macros take precedence over the ones defined in core (I think that's how the precedence works based on docs)

@QMalcolm
Copy link
Contributor Author

QMalcolm commented Sep 25, 2023

Is there a deprecation plan in place for these macros in dbt-utils? If the implementations of the two diverge this could lead to some surprising behaviour - especially if dbt-utils is installed and its date spine macros take precedence over the ones defined in core (I think that's how the precedence works based on docs)

Yes! Once this is merged I'm going to open a ticket on dbt-labs/dbt-utils that either I or @dbeatty10 (I believe) will take on. I found the old deprecation function before its removal, and I talked with @joellabes that it's fine to bring back.

Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

Thanks for moving this!!!

I remember there were conversations about moving dbt-utils into core. Are we still thinking of doing it? @dbeatty10

@dbeatty10
Copy link
Contributor

I remember there were conversations about moving dbt-utils into core. Are we still thinking of doing it? @dbeatty10

At this point in time, only planning on moving date_spine into dbt-core.

@QMalcolm QMalcolm merged commit aa86fdf into main Sep 25, 2023
51 checks passed
@QMalcolm QMalcolm deleted the qmalcolm--8172-add-date-spine-macros-to-core branch September 25, 2023 19:20
@FishtownBuildBot
Copy link
Collaborator

Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#4124

@graciegoheen
Copy link
Contributor

@dbeatty10 do we need to make any updates to dbt_utils docs? Or are we ok here?

@dbeatty10
Copy link
Contributor

@graciegoheen dbt-labs/dbt-utils#839 should also include any relevant update to the docs in dbt_utils, so added docs updates to the acceptance criteria of that issue.

QMalcolm added a commit that referenced this pull request Oct 9, 2023
* Add `date_spine` macro (and macros it depends on) from dbt-utils to core

The macros added are
- date_spine
- get_intervals_between
- generate_series
- get_powers_of_two

We're adding these to core because they are becoming more prevalently used
with the increase usage in the semantic layer. Basically if you are
using the semantic layer currently, then it is almost a requirement
to use dbt-utils, which is undesireable given the SL is supported directly
in core. The primary focus of this was to just add `date_spine`. However,
because `date_spine` depends on other macros, these other macros were
also moved.

* Add adapter tests for `get_powers_of_two` macro

* Add adapter tests for `generate_series` macro

* Add adapter tests for `get_intervals_between` macro

* Add adapter tests for `date_spine` macro

* Improve test fixture for `date_spine` macro to work with multiple adapters

* Cast to types to date in fixture_date_spine when targeting redshift

* Improve test fixture for `get_intervals_between` macro to work with multiple adapters

* changie doc for adding date_spine macro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes test macos user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-2855] [Feature] dbt_utils.date_spine should be added to core given new MetricFlow requirements
6 participants