pathwaycom/pathway · error · ValueError

Table.windowby() received extra args. It handles grouping on

Error message

Table.windowby() received extra args.
It handles grouping only by a single column.

What it means

Table.windowby() groups rows by exactly one time expression; unlike groupby it cannot take multiple positional grouping columns. Passing extra positional args (a second column, e.g. t.windowby(t.time, t.key, window=...)) raises this ValueError. Additional partitioning is expressed through the 'instance' keyword, not extra positional arguments.

Source

Thrown at python/pathway/internals/arg_handlers.py:56

        raise ValueError(
            "Table.groupby() received extra kwargs.\n"
            + "You probably want to use Table.groupby(...).reduce(**kwargs) to compute output columns."
        )
    return (self, *args), {
        "id": id,
        "sort_by": sort_by,
        "_filter_out_results_of_forgetting": _filter_out_results_of_forgetting,
        "instance": instance,
        "_skip_errors": _skip_errors,
        "_is_window": _is_window,
    }


def windowby_handler(
    self, time_expr, *args, window, behavior=None, instance=None, **kwargs
):
    if args:
        raise ValueError(
            "Table.windowby() received extra args.\n"
            + "It handles grouping only by a single column."
        )
    if kwargs:
        raise ValueError(
            "Table.windowby() received extra kwargs.\n"
            + "You probably want to use Table.windowby(...).reduce(**kwargs) to compute output columns."
        )
    return (self, time_expr), {
        "window": window,
        "behavior": behavior,
        "instance": instance,
    }


def join_kwargs_handler(*, allow_how: bool, allow_id: bool):
    def handler(self, other, *on, **kwargs):
        processed_kwargs = {}

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Use the instance keyword for secondary partitioning: t.windowby(t.time, window=w, instance=t.key).
  2. Remove extra positional columns if the window is meant to be global.
  3. For per-key tumbling windows combine instance=t.key with the desired window object.

Example fix

# before
t.windowby(t.time, t.key, window=pw.temporal.tumbling(duration=timedelta(minutes=1)))

# after
t.windowby(
    t.time,
    window=pw.temporal.tumbling(duration=timedelta(minutes=1)),
    instance=t.key,
)
Defensive patterns

Strategy: validation

Validate before calling

def checked_windowby(t, time_expr, *args, **kwargs):
    if args:
        raise TypeError("windowby takes only time_expr positionally; use instance= for extra grouping")
    return t.windowby(time_expr, **kwargs)

t2 = checked_windowby(t, t.time, window=w, instance=t.key)

Prevention

When it happens

Trigger: t.windowby(t.time, t.key, window=pw.temporal.tumbling(duration=...)); any call where a second positional argument is present before/after time_expr.

Common situations: Assuming windowby mirrors groupby's variadic signature; porting pandas resample('1min').groupby('key') style code; wanting per-key windows and not knowing about instance.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/e5a22e93c3890484. Report an issue: GitHub.