apache/beam · error · ValueError
No aggregation functions specified
Error message
No aggregation functions specified
What it means
The generic groupby aggregation helper in frames.py raises ValueError when kwargs contains no aggregation functions. Beam needs at least one column->(input, function) mapping to build the aggregation expression.
Solutions
- Provide at least one aggregation, e.g. gb.agg(mean_v=('v', 'mean')).
- Validate the kwargs dict is non-empty before calling: `if not aggs: raise ...` or skip the call.
- Ensure your dynamic kwargs construction actually populates entries for every column you intend to aggregate.
Example fix
# before
cols = {c: a for c, a in specs.items() if cond(c)}
df.groupby('k').agg(**cols) # cols may be {}
# after
if not cols:
cols = {c: ('mean',) for c in df.columns if c != 'k'}
df.groupby('k').agg(**cols) Defensive patterns
Strategy: validation
Validate before calling
if not agg_kwargs:
raise ValueError('agg requires at least one aggregation spec')
beam_df.groupby('k').agg(**agg_kwargs) Type guard
def has_aggs(kwargs: dict) -> bool:
return bool(kwargs) Try / catch
try:
out = beam_df.groupby('k').agg(**agg_kwargs)
except ValueError as e:
if 'No aggregation functions specified' in str(e):
logging.warning('Empty agg spec; skipping aggregation')
out = beam_df Prevention
- Validate dynamically-built kwargs dicts are non-empty before calling agg.
- Provide default aggregation specs when conditional construction yields nothing.
- Cover agg call sites with construction-time tests using empty proxy data.
When it happens
Trigger: Calling gb.agg() (or the internal _aggregate with empty kwargs) with no column/function pairs, e.g. df.groupby('k').agg() on a Beam deferred DataFrame.
Common situations: Building kwargs dynamically (loop/conditionals) that ends up empty; refactoring that removed all aggregation specs; passing only positional args that the helper ignores.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- GroupBy.agg(func= )
- Numeric aggregation ( ) on a DataFrame containing…
- Accessing a DeferredSeries with an iterator is sensitive to…
- Accessing an item by an integer key is order sensitive for…
- Accessing locals with @ is not yet supported…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/3e9474816ecab7ef.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/dataframe/frames.py:4716
keyword arguments and combines the results into a single DataFrame.
Args:
gb: The groupby instance (DeferredGroupBy).
*args: Additional positional arguments passed to the aggregation funcs.
**kwargs: A dictionary where each key is the column name to aggregate,
the value is a tuple containing the input column name and
the aggregation function to apply.
Returns:
DeferredDataFrame: A DataFrame that contains the aggregated results of
all specified columns.
Raises:
ValueError: If no aggregation functions are provided in the `kwargs`.
NotImplementedError: If the aggregation function type is unsupported.
"""
if not kwargs:
raise ValueError("No aggregation functions specified")
# Handle dictionary-like input for aggregation.
result_columns, result_frames = [], []
for col_name, (input_col, agg_fn) in kwargs.items():
frame = _handle_agg_function(
gb[input_col], agg_fn, f"agg_{col_name}", *args
)
result_frames.append(frame)
result_columns.append(col_name)
# Combine all the resulting DeferredDataFrames into a single DataFrame.
return DeferredDataFrame(
expressions.ComputedExpression(
"agg",
lambda *results: pd.concat(results, axis=1, keys=result_columns),
[frame._expr for frame in result_frames],
requires_partition_by=partitionings.Index(),
preserves_partition_by=partitionings.Singleton(),View on GitHub (pinned to 12126d8942)