Skip to content

Commit

Permalink
Update AddGroupByMetrics to be singular AddGroupByMetric - should onl…
Browse files Browse the repository at this point in the history
…y ever accept one group by metric
  • Loading branch information
courtneyholcomb committed Apr 25, 2024
1 parent a0bee88 commit 0a400a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
from metricflow.plan_conversion.convert_to_sql_plan import ConvertToSqlPlanResult
from metricflow.plan_conversion.instance_converters import (
AddGroupByMetrics,
AddGroupByMetric,
AddLinkToLinkableElements,
AddMetadata,
AddMetrics,
Expand Down Expand Up @@ -740,7 +740,7 @@ def visit_compute_metrics_node(self, node: ComputeMetricsNode) -> SqlDataSet:
metric_subquery_entity_links=entity_instance.spec.entity_links,
),
)
transform_func = AddGroupByMetrics([group_by_metric_instance])
transform_func = AddGroupByMetric(group_by_metric_instance)

output_instance_set = output_instance_set.transform(transform_func)

Expand Down
8 changes: 4 additions & 4 deletions metricflow/plan_conversion/instance_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,19 +745,19 @@ def transform(self, instance_set: InstanceSet) -> InstanceSet: # noqa: D102
)


class AddGroupByMetrics(InstanceSetTransform[InstanceSet]):
class AddGroupByMetric(InstanceSetTransform[InstanceSet]):
"""Adds the given metric instances to the instance set."""

def __init__(self, group_by_metric_instances: List[GroupByMetricInstance]) -> None: # noqa: D107
self._group_by_metric_instances = group_by_metric_instances
def __init__(self, group_by_metric_instance: GroupByMetricInstance) -> None: # noqa: D107
self._group_by_metric_instance = group_by_metric_instance

def transform(self, instance_set: InstanceSet) -> InstanceSet: # noqa: D102
return InstanceSet(
measure_instances=instance_set.measure_instances,
dimension_instances=instance_set.dimension_instances,
time_dimension_instances=instance_set.time_dimension_instances,
entity_instances=instance_set.entity_instances,
group_by_metric_instances=instance_set.group_by_metric_instances + tuple(self._group_by_metric_instances),
group_by_metric_instances=instance_set.group_by_metric_instances + (self._group_by_metric_instance,),
metric_instances=instance_set.metric_instances,
metadata_instances=instance_set.metadata_instances,
)
Expand Down

0 comments on commit 0a400a5

Please sign in to comment.