-
Notifications
You must be signed in to change notification settings - Fork 97
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
Support conversion metrics with custom grain #1475
Conversation
ec3faac
to
c93914d
Compare
2d1d31a
to
57228ab
Compare
98d16f5
to
7aa19d7
Compare
57228ab
to
ba8bdb2
Compare
a470bdb
to
fc171b4
Compare
from metricflow_semantics.specs.metric_spec import MetricSpec | ||
from metricflow_semantics.specs.time_dimension_spec import TimeDimensionSpec | ||
|
||
if TYPE_CHECKING: |
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.
Needed to resolve circular imports.
ab0e7fa
to
9a41e79
Compare
Adds all_linkable_specs_required_for_source_nodes property. Storing this on SourceNodeRecipe allows us to keep logic for converting to base grain in one place instead of needing to propogate that in several places and add a comment explaining each one. This commit also adds a little bit of type cleanup to the same class.
7576c0e
to
b636dd6
Compare
b636dd6
to
1cd7601
Compare
ORDER BY subq_28.ds__day DESC | ||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING | ||
) AS ds__day | ||
, FIRST_VALUE(subq_28.metric_time__day) OVER ( |
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.
Is it expected that we still use metric_time__day
in the interim calculations here? Looks like we use both metric_time__day
and metric_time__martian_day
in the window functions, even though only metric_time__martian_day
was in the group by.
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.
how does cumulative windows work for custom grains? We have metric_time__day
here because that's what's used for the conversion window calculation (ie., look at line 126 below for the join condition). So metric_time__day
is here because it's used for the conversion window and metric_time__martian_day
is there because we will need it when grouping by it.
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.
actually, looking at this, we use ds__day
to do the calculation. There's probably some wonky thing happening with the column's I passed into the conversion node, not blocking, but I'll take a look.
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.
Cumulative windows can't use custom grains yet - that's part of the implementation we were discussing at MF team meeting today!
I think non-default grains are relevant, though. If you look at this SQL snapshot you can see an example of the window function we implement for that.
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.
But it sounds like the PR you put up today was a fix for what you mentioned here!
1cd7601
to
22253ce
Compare
22253ce
to
05aed81
Compare
ORDER BY subq_28.ds__day DESC | ||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING | ||
) AS ds__day | ||
, FIRST_VALUE(subq_28.metric_time__day) OVER ( |
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.
how does cumulative windows work for custom grains? We have metric_time__day
here because that's what's used for the conversion window calculation (ie., look at line 126 below for the join condition). So metric_time__day
is here because it's used for the conversion window and metric_time__martian_day
is there because we will need it when grouping by it.
@@ -0,0 +1,6 @@ | |||
kind: Features | |||
body: Support cumulative metrics queried with custom granularities. |
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.
Support conversion** metrics
{{ render_date_trunc("ds", TimeGranularity.DAY) }} AS ds__day | ||
, user_id AS user | ||
, 1 AS buys | ||
, GEN_RANDOM_UUID() AS mf_internal_uuid |
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.
Need to swap GEN_RANDOM_UUID()
with {{ generate_random_uuid() }}
Support for conversion metrics used with custom granularities in the group by or the where filter.