-
Notifications
You must be signed in to change notification settings - Fork 99
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
Dataflow Plan for Min & Max of Distinct Values Query #854
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8cdfc5e
Add MinMaxNode and render SQL
courtneyholcomb c49d4a7
Handle min_max_only param in queries
courtneyholcomb 041309c
Write Dataflow tests
courtneyholcomb eea8492
Write integration tests
courtneyholcomb 11856b8
Write SQL tests
courtneyholcomb 292e5fe
Update SQL engine snapshots
courtneyholcomb 7228c76
Merge main
courtneyholcomb f5cb02d
Move min/max column name logic to MetadataSpec & add new metadata ins…
courtneyholcomb fd6e0f7
Update SQL snapshots
courtneyholcomb 2d80dea
Merge main
courtneyholcomb 4cfbbcc
Use dundered column names for min/max cols
courtneyholcomb f5f471e
Merge branch 'main' into court/distinct-values-range
courtneyholcomb 14f619c
Pin DSI temporarily to avoid breaking changes
courtneyholcomb 5cc381b
Merge main
courtneyholcomb b036e4e
Add validation for min_max_only to match new structure
courtneyholcomb 88c6709
Merge main
courtneyholcomb ef1648e
Update snapshots
courtneyholcomb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
|
||
from typing_extensions import override | ||
|
||
from metricflow.query.group_by_item.resolution_path import MetricFlowQueryResolutionPath | ||
from metricflow.query.issues.issues_base import ( | ||
MetricFlowQueryIssueType, | ||
MetricFlowQueryResolutionIssue, | ||
) | ||
from metricflow.query.resolver_inputs.base_resolver_inputs import MetricFlowQueryResolverInput | ||
|
||
|
||
@dataclass(frozen=True) | ||
class InvalidMinMaxOnlyIssue(MetricFlowQueryResolutionIssue): | ||
"""Describes an issue with the query where the limit is invalid.""" | ||
|
||
min_max_only: bool | ||
|
||
@staticmethod | ||
def from_parameters( # noqa: D | ||
min_max_only: bool, query_resolution_path: MetricFlowQueryResolutionPath | ||
) -> InvalidMinMaxOnlyIssue: | ||
return InvalidMinMaxOnlyIssue( | ||
issue_type=MetricFlowQueryIssueType.ERROR, | ||
parent_issues=(), | ||
query_resolution_path=query_resolution_path, | ||
min_max_only=min_max_only, | ||
) | ||
|
||
@override | ||
def ui_description(self, associated_input: MetricFlowQueryResolverInput) -> str: | ||
return "`min_max_only` must be used with exactly one `group_by`, and cannot be used with `metrics`, `order_by`, or `limit`." | ||
|
||
@override | ||
def with_path_prefix(self, path_prefix_node: MetricFlowQueryResolutionPath) -> InvalidMinMaxOnlyIssue: | ||
return InvalidMinMaxOnlyIssue( | ||
issue_type=self.issue_type, | ||
parent_issues=tuple(issue.with_path_prefix(path_prefix_node) for issue in self.parent_issues), | ||
query_resolution_path=self.query_resolution_path.with_path_prefix(path_prefix_node), | ||
min_max_only=self.min_max_only, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
ResolverInputForGroupByItem, | ||
ResolverInputForLimit, | ||
ResolverInputForMetric, | ||
ResolverInputForMinMaxOnly, | ||
ResolverInputForOrderByItem, | ||
ResolverInputForQuery, | ||
ResolverInputForQueryLevelWhereFilterIntersection, | ||
|
@@ -307,11 +308,13 @@ def parse_and_validate_query( | |
where_constraint_str: Optional[str] = None, | ||
order_by_names: Optional[Sequence[str]] = None, | ||
order_by: Optional[Sequence[OrderByQueryParameter]] = None, | ||
min_max_only: bool = False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @courtneyholcomb please coordinate with @plypaul , this file changed dramatically in his pending stack of changes. |
||
) -> MetricFlowQuerySpec: | ||
"""Parse the query into spec objects, validating them in the process. | ||
|
||
e.g. make sure that the given metric is a valid metric name. | ||
""" | ||
# TODO: validate min_max_only - can only be called for non-metric queries | ||
assert_at_most_one_arg_set(metric_names=metric_names, metrics=metrics) | ||
assert_at_most_one_arg_set(group_by_names=group_by_names, group_by=group_by) | ||
assert_at_most_one_arg_set(order_by_names=order_by_names, order_by=order_by) | ||
|
@@ -423,13 +426,15 @@ def parse_and_validate_query( | |
resolver_inputs_for_order_by.extend(MetricFlowQueryParser._parse_order_by(order_by=order_by)) | ||
|
||
resolver_input_for_limit = ResolverInputForLimit(limit=limit) | ||
resolver_input_for_min_max_only = ResolverInputForMinMaxOnly(min_max_only=min_max_only) | ||
|
||
resolver_input_for_query = ResolverInputForQuery( | ||
metric_inputs=tuple(resolver_inputs_for_metrics), | ||
group_by_item_inputs=tuple(resolver_inputs_for_group_by_items), | ||
order_by_item_inputs=tuple(resolver_inputs_for_order_by), | ||
limit_input=resolver_input_for_limit, | ||
filter_input=resolver_input_for_filter, | ||
min_max_only=resolver_input_for_min_max_only, | ||
) | ||
|
||
logger.info("Resolver input for query is:\n" + indent_log_line(mf_pformat(resolver_input_for_query))) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@plypaul is this still ok given your other changes to an enumerated ID prefix type?