-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[CT-2855] [Feature] dbt_utils.date_spine should be added to core given new MetricFlow requirements #8172
[CT-2855] [Feature] dbt_utils.date_spine should be added to core given new MetricFlow requirements #8172
Comments
Keen observation @graciegoheen 🧠 In addition to moving Maybe something like this (completely untested)? {% macro default__metricflow_time_spine(start_date="2000-01-01", end_date="2030-01-01") -%}
{# -- Do some kind of checking here to make sure the provided date strings are in valid ISO 8601 / RFC 3339 format #}
with days as (
{{
dbt.date_spine(
'day',
cast({{ dbt.string_literal(start_date) }} as {{ api.Column.translate_type("date")) }}),
cast({{ dbt.string_literal(end_date) }} as {{ api.Column.translate_type("date")) }})
)
}}
)
select cast(date_day as {{ api.Column.translate_type("date")) }}) as date_day
from days Note: we don't have a cross-database data type macro for We also don't have a well-known cross-database |
Notes from TR:
|
@graciegoheen could you open an issue for this in dbt-utils (and/or open a PR)? |
@dbeatty10 Do you want me to do that now? Or wait until this is picked up? |
Ideally, whoever picks up this one would also pick up the dbt-utils one at the same time. Alternatively, we'd need to make sure someone else is available to pick up the dbt-utils work at the same time. Would probably be worth opening the issue in dbt-utils now so that it's ready either way. |
Is this your first time submitting a feature request?
Describe the feature
The new metric spec requires a Time Spine model - documented here.
The
metricflow_time_spine
model to copy/paste into your project uses the dbt_utilsdate_spine
macro. Given that this macro will be used by all dbt users who want to define metrics, should we bring it into dbt-core?Additionally, should we handle casting within the macro itself? Currently, the example requires that you input appropriate casting to a date data type:
But not all warehouses have the
to_date
function. If we handled date casting within thedate_spine
macro, we could have a singlemetricflow_time_spine
example that would work in all data warehouses.Describe alternatives you've considered
We keep
date_spine
indbt_utils
and require that people installdbt_utils
if they want to use metric flow.Who will this benefit?
dbt users who want to define metrics in their project
Are you interested in contributing this feature?
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: