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

Conversion Metrics #916

Merged
merged 14 commits into from
Dec 16, 2023
Prev Previous commit
Next Next commit
fix lookups and resolvers
WilliamDee committed Dec 16, 2023
commit 08d10f080b31366a4b4ad1d340b0782a3e09effc
6 changes: 6 additions & 0 deletions metricflow/model/semantics/linkable_spec_resolver.py
Original file line number Diff line number Diff line change
@@ -500,6 +500,12 @@ def __init__(
or metric.type is MetricType.RATIO
):
linkable_sets_for_measure.append(self._get_linkable_element_set_for_measure(measure))
elif metric.type is MetricType.CONVERSION:
if measure == metric.conversion_params.base_measure_reference:
# Only can query against the base measure's linkable elements
WilliamDee marked this conversation as resolved.
Show resolved Hide resolved
# as it joins everything back to the base measure data set so
# there is no way of getting the conversion elements
linkable_sets_for_measure.append(self._get_linkable_element_set_for_measure(measure))
else:
assert_values_exhausted(metric.type)

4 changes: 3 additions & 1 deletion metricflow/model/semantics/metric_lookup.py
Original file line number Diff line number Diff line change
@@ -141,7 +141,9 @@ def configured_input_measure_for_metric( # noqa: D
if metric.type is MetricType.CUMULATIVE or metric.type is MetricType.SIMPLE:
assert len(metric.input_measures) == 1, "Simple and cumulative metrics should have one input measure."
return metric.input_measures[0]
elif metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED:
elif (
metric.type is MetricType.RATIO or metric.type is MetricType.DERIVED or metric.type is MetricType.CONVERSION
):
return None
else:
assert_values_exhausted(metric.type)