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

Enable different granularities for metrics with time offset #426

Closed
wants to merge 7 commits into from

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented Feb 3, 2023

With the current placement of the JoinToTimeSpineNode in the dataflow plan, we filter down to time columns with the requested granularity BEFORE joining to time spine. Since joining to time spine expects an unaggregated time column, this means queries with any granularity besides DAY don't return expected results. Here, we move the time spine join to happen before time column aggregation.
For cumulative metrics, we also needed to change the order of the dataflow plan, from FilterElementsNode -> JoinOverTimeRangeNode (both required) to JoinOverTimeRangeNode (optional, only used if a time dimension is requested) -> JoinToTimeSpineNode (optional, only used for offset metrics) -> FilterElementsNode. This ensures we'll have the columns needed when joining to time spine.
Unrelated to time offset, this change also removes the unnecessary JoinOverTimeRangeNode step for a cumulative metric queried without a time dimension, which 1) does nothing in SQL and 2) might result in inaccurate costing for that query.

@@ -209,7 +209,7 @@ metric:
- txn_revenue
---
metric:
name: "every_two_days_bookers" # because the bookings test data only spans 3 days
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer true

@@ -197,34 +197,15 @@ def _make_time_spine_data_set(

# If the requested granularity is the same as the granularity of the spine, do a direct select.
if metric_time_dimension_instance.spec.time_granularity == time_spine_source.time_column_granularity:
return SqlDataSet(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed some redundant code here

@courtneyholcomb courtneyholcomb marked this pull request as ready for review February 6, 2023 21:46
Copy link
Contributor

@plypaul plypaul left a comment

Choose a reason for hiding this comment

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

As per discussion, there are some uncertainties on how the feature should work (from a product perspective), and we haven't prioritized a resolution. Since I'm using github to manage my review queue, marking this is Request Changes so that it's not on my list.

@courtneyholcomb
Copy link
Contributor Author

PR outdated; new one here #726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants