pathwaycom/pathway · error · ValueError

Setting strict=True in pathway.reducers.sum when the column

Error message

Setting strict=True in pathway.reducers.sum when the column has type int is not allowed

What it means

pathway.reducers.sum(strict=True) enables floating-point strict summation (no compensation for accumulated error). For integer columns the engine uses exact integer summation, where strictness is meaningless, so engine_reducer_unary explicitly rejects this combination with a ValueError instead of silently ignoring the flag.

Source

Thrown at python/pathway/internals/reducers.py:128

class SumReducer(UnaryReducer):
    def __init__(self, name: str, strict: bool) -> None:
        super().__init__(name=name)
        self.strict = strict

    def return_type_unary(self, arg_type: dt.DType, id_type: dt.DType) -> dt.DType:
        for allowed_dtype in [dt.FLOAT, dt.ANY_ARRAY]:
            if dt.dtype_issubclass(arg_type, allowed_dtype):
                return arg_type
        raise TypeError(
            f"Pathway does not support using reducer {self}"
            + f" on column of type {arg_type}.\n"
        )

    def engine_reducer_unary(self, arg_type: dt.DType) -> api.Reducer:
        if arg_type == dt.INT:
            if self.strict:
                raise ValueError(
                    "Setting strict=True in pathway.reducers.sum when the column has type int is not allowed"
                )
            return api.Reducer.INT_SUM
        elif isinstance(arg_type, dt.Array):
            return api.Reducer.array_sum(self.strict)
        else:
            return api.Reducer.float_sum(self.strict)


class SortedTupleWrappingReducer(UnaryReducerWithDefault):
    _skip_nones: bool

    def __init__(
        self,
        *,
        name: str,
        engine_reducer: api.Reducer,
        skip_nones: bool,

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Drop strict=True for integer columns: pw.reducers.sum(pw.this.col) — integer summation is already exact.
  2. Or cast the column to float if you truly want float strict summation: pw.reducers.sum(pw.this.col.astype(float), strict=True).

Example fix

# before
agg = t.reduce(s=pw.reducers.sum(t.qty, strict=True))  # qty: int

# after
agg = t.reduce(s=pw.reducers.sum(t.qty))
Defensive patterns

Strategy: validation

Validate before calling

import pathway as pw
from pathway.internals import dtype as dt

def strict_ok(table: pw.Table, name: str) -> bool:
    return table.schema._dtypes()[name] != dt.INT

Prevention

When it happens

Trigger: Calling pw.reducers.sum(strict=True) on a column whose dtype is exactly dt.INT, e.g. table.reduce(s=pw.reducers.sum(pw.this.count, strict=True)) where count: int.

Common situations: Copy-pasting strict=True from a float pipeline onto an int column; toggling strict for accuracy without checking the column dtype.

Related errors


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