-
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
Query suggestions for GroupByMetrics
#1197
Changes from all commits
5023f34
5b45d3b
f2c78bd
49ff11f
347c231
fd3657e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
from typing import List, Sequence | ||
|
||
from typing_extensions import override | ||
|
||
from metricflow_semantics.specs.patterns.spec_pattern import SpecPattern | ||
from metricflow_semantics.specs.spec_classes import ( | ||
InstanceSpec, | ||
LinkableInstanceSpec, | ||
) | ||
from metricflow_semantics.specs.spec_set import group_specs_by_type | ||
|
||
|
||
class NoGroupByMetricPattern(SpecPattern): | ||
"""Matches to linkable specs, but only if they're not group by metrics. | ||
|
||
Group by metrics are allowed in filters but not in the query input group by. | ||
""" | ||
|
||
@override | ||
def match(self, candidate_specs: Sequence[InstanceSpec]) -> Sequence[LinkableInstanceSpec]: | ||
specs_to_return: List[LinkableInstanceSpec] = [] | ||
spec_set = group_specs_by_type(candidate_specs) | ||
specs_to_return.extend(spec_set.time_dimension_specs) | ||
specs_to_return.extend(spec_set.dimension_specs) | ||
specs_to_return.extend(spec_set.entity_specs) | ||
|
||
return specs_to_return |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ Error #1: | |
The given input does not exactly match any known metrics. | ||
|
||
Suggestions: | ||
['bookings', 'booking_fees', 'booking_value', 'instant_bookings', 'booking_payments', 'max_booking_value'] | ||
['bookings', 'booking_fees', 'booking_value', 'booking_payments', 'instant_bookings', 'booking_value_p99'] | ||
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. So max_booking_value was tied with booking_value_p99 here and the sort pushed the latter into 6th place? 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. Correct! 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. Well it's actually like a 7-way tie between a bunch of metrics. |
||
|
||
Query Input: | ||
|
||
|
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.
LOL. Where's the Oscar the Grouch garbage can emoji when I need one...