perspective-dev/perspective · error · ValueError
Unknown aggregate
Error message
Unknown aggregate '{agg_name}' What it means
get_polars_agg_expr looks up the aggregate name in AGG_MAP to build a Polars expression; names outside the map (typos like "mean" vs "avg", or client-sent invalid config from a view request) cannot be translated, so the rollup/group-by pipeline raises ValueError before any computation runs.
Solutions
- Use an aggregate name present in AGG_MAP (e.g. count, sum, avg, first, last)
- Check the client's aggregates config for typos or aggregates unsupported by the Polars virtual server
- Add the missing aggregate to AGG_MAP if it is a legitimately supported operation
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at rust/perspective-python/perspective/virtual_servers/polars.py:364 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of perspective-dev/perspective@11c8238c0c (2026-09-09).
Data as JSON: /api/errors/74c84d4eb77954d9.
Report an issue: GitHub.
Appendix: source
Thrown at rust/perspective-python/perspective/virtual_servers/polars.py:364
mask = mask & (col_expr <= value)
return df.filter(mask)
def get_polars_agg_expr(col, agg_name, filter_expr=None):
"""Convert an aggregate name to a Polars expression."""
if isinstance(agg_name, list):
agg_name = agg_name[0]
if isinstance(agg_name, dict):
agg_name = "first"
expr = pl.col(col)
if filter_expr is not None:
expr = expr.filter(filter_expr)
if agg_name in AGG_MAP:
return AGG_MAP[agg_name](expr)
msg = f"Unknown aggregate '{agg_name}'"
raise ValueError(msg)
def default_aggregate(col_name, df):
"""Return the default aggregate for a column based on its type."""
dtype = df[col_name].dtype
psp_type = polars_type_to_psp(dtype)
if psp_type in ("integer", "float"):
return "sum"
return "count"
def build_rollup(df, group_by, columns, aggregates, col_alias):
"""Emulate GROUP BY ROLLUP using multiple group_by operations."""
n = len(group_by)
frames = []
data_columns = [c for c in columns if c not in group_by]
for level in range(n + 1):View on GitHub (pinned to 11c8238c0c)