diff --git a/python/arcticdb/version_store/processing.py b/python/arcticdb/version_store/processing.py index c23c15f260..336896065d 100644 --- a/python/arcticdb/version_store/processing.py +++ b/python/arcticdb/version_store/processing.py @@ -503,16 +503,16 @@ def agg(self, aggregations: Dict[str, Union[str, tuple[str, str]]]): len(self.clauses) and isinstance(self.clauses[-1], _GroupByClause), f"Aggregation only makes sense after groupby", ) - for v in aggregations.values(): + for k, v in aggregations.items(): check(isinstance(v, (str, tuple)), f"Values in agg dict expected to be strings or tuples, received {v} of type {type(v)}") if isinstance(v, str): - v = v.lower() + aggregations[k] = v.lower() elif isinstance(v, tuple): check( len(v) == 2 and (isinstance(v[0], str) and isinstance(v[1], str)), f"Tuple values in agg dict expected to have 2 string elements, received {v}" ) - v[1].lower() + aggregations[k] = (v[0], v[1].lower()) self.clauses.append(_AggregationClause(self.clauses[-1].grouping_column, aggregations)) self._python_clauses.append(PythonAggregationClause(aggregations)) diff --git a/python/tests/unit/arcticdb/version_store/test_aggregation.py b/python/tests/unit/arcticdb/version_store/test_aggregation.py index d4accb00f0..960bc11a15 100644 --- a/python/tests/unit/arcticdb/version_store/test_aggregation.py +++ b/python/tests/unit/arcticdb/version_store/test_aggregation.py @@ -474,8 +474,8 @@ def test_named_agg(lmdb_version_store_tiny_segment): q = q.groupby("grouping_column").agg( { "agg_column_sum": ("agg_column", "sum"), - "agg_column_mean": ("agg_column", "mean"), - "agg_column": "min", + "agg_column_mean": ("agg_column", "MEAN"), + "agg_column": "MIN", } ) print(f"{q}")