From b0a1f16239c5cf9649005dd0924f28eab40600c2 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 25 Apr 2024 09:29:57 -0700 Subject: [PATCH] Update AddGroupByMetrics to be singular AddGroupByMetric - should only ever accept one group by metric --- metricflow/plan_conversion/dataflow_to_sql.py | 4 ++-- metricflow/plan_conversion/instance_converters.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 9c3b00c313..a290b487f6 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -68,7 +68,7 @@ from metricflow.dataset.sql_dataset import SqlDataSet from metricflow.plan_conversion.convert_to_sql_plan import ConvertToSqlPlanResult from metricflow.plan_conversion.instance_converters import ( - AddGroupByMetrics, + AddGroupByMetric, AddLinkToLinkableElements, AddMetadata, AddMetrics, @@ -749,7 +749,7 @@ def visit_compute_metrics_node(self, node: ComputeMetricsNode) -> SqlDataSet: transform_func: InstanceSetTransform = AddMetrics(metric_instances) if group_by_metric_instance: - transform_func = AddGroupByMetrics([group_by_metric_instance]) + transform_func = AddGroupByMetric(group_by_metric_instance) output_instance_set = output_instance_set.transform(transform_func) diff --git a/metricflow/plan_conversion/instance_converters.py b/metricflow/plan_conversion/instance_converters.py index 2bdac0c8ea..3d7562b450 100644 --- a/metricflow/plan_conversion/instance_converters.py +++ b/metricflow/plan_conversion/instance_converters.py @@ -744,11 +744,11 @@ 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( @@ -756,7 +756,7 @@ def transform(self, instance_set: InstanceSet) -> InstanceSet: # noqa: D102 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, )