pathwaycom/pathway · error · ValueError

Cannot provide both [predicate, max_gap] at the same time.

Error message

Cannot provide both [predicate, max_gap] at the same time.

What it means

Error "Cannot provide both [predicate, max_gap] at the same time." thrown in pathwaycom/pathway.

Source

Thrown at python/pathway/stdlib/temporal/_window.py:559

    ... pw.this._pw_window_start,
    ... pw.this._pw_window_end,
    ... min_t=pw.reducers.min(pw.this.t),
    ... max_v=pw.reducers.max(pw.this.v),
    ... count=pw.reducers.count(),
    ... )
    >>> pw.debug.compute_and_print(result, include_id=False)
    _pw_instance | _pw_window_start | _pw_window_end | min_t | max_v | count
    0            | 1                | 2              | 1     | 10    | 2
    0            | 4                | 4              | 4     | 3     | 1
    0            | 8                | 10             | 8     | 8     | 3
    1            | 1                | 2              | 1     | 16    | 2
    """
    if predicate is None and max_gap is None:
        raise ValueError(
            "At least one of the parameters [predicate, max_gap] should be provided."
        )
    elif predicate is not None and max_gap is not None:
        raise ValueError("Cannot provide both [predicate, max_gap] at the same time.")
    return _SessionWindow(predicate=predicate, max_gap=max_gap)


@check_arg_types
@trace_user_frame
def sliding(
    hop: int | float | datetime.timedelta,
    duration: int | float | datetime.timedelta | None = None,
    ratio: int | None = None,
    origin: int | float | datetime.datetime | None = None,
) -> Window:
    """Allows grouping together elements within a window of a given length sliding
    across ordered time-like data column according to a specified interval (hop)
    starting from a given origin.

    Note:
        Usually used as an argument of `.windowby()`.
        Exactly one of the arguments `hop` or `ratio` should be provided.

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Provide only one of predicate or max_gap, not both.

Example fix

pw.temporal.sessionby(max_gap=timedelta(minutes=5))

When it happens

Trigger: Thrown at python/pathway/stdlib/temporal/_window.py:559 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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