Skip to content

Commit

Permalink
Fix specifiyng aggregation operators with capital letters
Browse files Browse the repository at this point in the history
  • Loading branch information
alexowens90 committed Apr 2, 2024
1 parent 61e01d1 commit f70ffd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions python/arcticdb/version_store/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions python/tests/unit/arcticdb/version_store/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit f70ffd9

Please sign in to comment.