-
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
Allow measures that join to time spine to use agg_time_dim
#1005
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
…_specs -> requested_agg_time_dimension_specs
1e43d95
to
8b0a072
Compare
8b0a072
to
fd61f3c
Compare
agg_time_dim
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.
Checking in before approving - are there any cases where this might result in an ambiguous plan?
I'm thinking of a situation where someone has multiple metrics, or some combination nested metric, and they group by this agg_time_dimension and also metric_time. I'm not even sure if that's a valid query ordinarily, honestly.
query_contains_agg_time_dimension = queried_linkable_specs.contains_metric_time | ||
if not query_contains_agg_time_dimension: | ||
valid_agg_time_dimensions = self._semantic_model_lookup.get_agg_time_dimension_specs_for_measure( | ||
measure_spec.reference | ||
) | ||
query_contains_agg_time_dimension = bool( | ||
set(queried_linkable_specs.time_dimension_specs).intersection(set(valid_agg_time_dimensions)) | ||
) | ||
|
||
if query_contains_agg_time_dimension: |
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.
Yeah if we have some kind of helper I think it'll clean up a lot of these conditionals as well, because it'll hide the wonky logic inside of the helper and this can become something like:
if query_contains_agg_time_dimension(queried_linkable_specs, measure_spec):
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.
Updated!
subq_5.ds AS booking__ds__day | ||
, COALESCE(subq_3.bookings, 0) AS bookings_fill_nulls_with_0 | ||
FROM {{ source_schema }}.mf_time_spine subq_5 | ||
LEFT OUTER JOIN ( |
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.
Ok, so previously this would have just run the query but skipped the join, correct? That seems strange and incorrect to me.
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.
The logic there was that if there's no time dimension to join to, we can't join to time spine anyway.
And then, if there is a time dimension that isn't agg time, should we time spine join to that dimension? Seems inconsistent if we're treating it like any other categorical dimension in all other ways.
@tlento This clause should be able to execute for as many measures as are requested, each join will happen in its own subquery. We're checking for the |
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.
This clause should be able to execute for as many measures as are requested, each join will happen in its own subquery.
Duh, of course it does, thank you.
Also, in re-reading that comment, I think the right answer for people duplicating their requested time dimensions across metrics is "don't do that" - I'm sure I'm missing some super critical use case where that's a totally reasonable thing to do, but it doesn't sound reasonable when I read it out loud.
Resolves #1009
Description
Some measures specify that they should be joined to time spine in the YAML. We only execute this join if metric time is queried, since that's the only time joining to time spine is allowed. Since we're relaxing that restriction, we now can execute the join if
agg_time_dimension
is queried.