pathwaycom/pathway · error · ValueError
Table.groupby() received id argument and is grouped by a sin
Error message
Table.groupby() received id argument and is grouped by a single column, but the arguments are not equal. Consider using <table>.groupby(id=...), skipping the positional argument.
What it means
When Table.groupby() receives both a single positional column and id=, Pathway compares the underlying column objects (args[0]._column != id._column). If they are not the very same column, ValueError is raised: passing two different single columns (one positional, one as id) is ambiguous — the fix is to pass the intended column only via id=.
Source
Thrown at python/pathway/internals/table.py:1243
... ''')
>>> t2 = t1.groupby(t1.pet, t1.owner).reduce(t1.owner, t1.pet, ageagg=pw.reducers.sum(t1.age))
>>> pw.debug.compute_and_print(t2, include_id=False)
owner | pet | ageagg
Alice | cat | 8
Alice | dog | 10
Bob | dog | 16
"""
if instance is not None:
args = (*args, instance)
if id is not None:
if len(args) == 0:
args = (id,)
elif len(args) > 1:
raise ValueError(
"Table.groupby() cannot have id argument when grouping by multiple columns."
)
elif args[0]._column != id._column:
raise ValueError(
"Table.groupby() received id argument and is grouped by a single column,"
+ " but the arguments are not equal.\n"
+ "Consider using <table>.groupby(id=...), skipping the positional argument."
)
for arg in args:
if not isinstance(arg, expr.ColumnReference):
if isinstance(arg, str):
raise ValueError(
f"Expected a ColumnReference, found a string. Did you mean <table>.{arg}"
+ f" instead of {repr(arg)}?"
)
else:
raise ValueError(
"All Table.groupby() arguments have to be a ColumnReference."
)
self._check_for_disallowed_types(*args)View on GitHub (pinned to fa2f74a464)
Solutions
- Remove the positional argument and keep only id=: t.groupby(id=t.a)
- Or remove id= and keep the plain positional column if custom ids are not needed
Example fix
# before g = t.groupby(t.key, id=t.user_id) # two different columns -> ValueError # after g = t.groupby(id=t.user_id)
Defensive patterns
Strategy: validation
Validate before calling
def id_matches_single_arg(args, id) -> bool:
return id is None or len(args) != 1 or args[0]._column == id._column Prevention
- Pass the grouping id column exclusively via id=, never also positionally
- Clean up leftover positional args when refactoring to id= form
When it happens
Trigger: t.groupby(t.a, id=t.b) with a != b; t.groupby(id=t.id, *args left over from a refactor) where the positional column is a transform of the id column rather than the identical ColumnReference.
Common situations: Refactoring a call from t.groupby(t.id) to t.groupby(id=t.id) and leaving the positional argument in; passing a copy/derived reference that is a different column object.
Related errors
- You cannot use {dep.to_column_expression()} in this reduce s
- You cannot use {dep.to_column_expression()} in this context.
- Expected a ColumnReference, found a string. Did you mean thi
- In JoinResult.groupby() all arguments have to be a ColumnRef
- Table.groupby() cannot have id argument when grouping by mul
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/e782c4d5cfac3c94.
Report an issue: GitHub.