{"record":{"id":"976c1df887b8d6df","repo":"pathwaycom/pathway","slug":"setting-strict-true-in-pathway-reducers-sum-when-t","errorCode":null,"errorMessage":"Setting strict=True in pathway.reducers.sum when the column has type int is not allowed","messagePattern":"Setting strict=True in pathway\\.reducers\\.sum when the column has type int is not allowed","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/reducers.py","lineNumber":128,"sourceCode":"\nclass SumReducer(UnaryReducer):\n    def __init__(self, name: str, strict: bool) -> None:\n        super().__init__(name=name)\n        self.strict = strict\n\n    def return_type_unary(self, arg_type: dt.DType, id_type: dt.DType) -> dt.DType:\n        for allowed_dtype in [dt.FLOAT, dt.ANY_ARRAY]:\n            if dt.dtype_issubclass(arg_type, allowed_dtype):\n                return arg_type\n        raise TypeError(\n            f\"Pathway does not support using reducer {self}\"\n            + f\" on column of type {arg_type}.\\n\"\n        )\n\n    def engine_reducer_unary(self, arg_type: dt.DType) -> api.Reducer:\n        if arg_type == dt.INT:\n            if self.strict:\n                raise ValueError(\n                    \"Setting strict=True in pathway.reducers.sum when the column has type int is not allowed\"\n                )\n            return api.Reducer.INT_SUM\n        elif isinstance(arg_type, dt.Array):\n            return api.Reducer.array_sum(self.strict)\n        else:\n            return api.Reducer.float_sum(self.strict)\n\n\nclass SortedTupleWrappingReducer(UnaryReducerWithDefault):\n    _skip_nones: bool\n\n    def __init__(\n        self,\n        *,\n        name: str,\n        engine_reducer: api.Reducer,\n        skip_nones: bool,","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/reducers.py#L110-L146","documentation":"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.","triggerScenarios":"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.","commonSituations":"Copy-pasting strict=True from a float pipeline onto an int column; toggling strict for accuracy without checking the column dtype.","solutions":["Drop strict=True for integer columns: pw.reducers.sum(pw.this.col) — integer summation is already exact.","Or cast the column to float if you truly want float strict summation: pw.reducers.sum(pw.this.col.astype(float), strict=True)."],"exampleFix":"# before\nagg = t.reduce(s=pw.reducers.sum(t.qty, strict=True))  # qty: int\n\n# after\nagg = t.reduce(s=pw.reducers.sum(t.qty))","handlingStrategy":"validation","validationCode":"import pathway as pw\nfrom pathway.internals import dtype as dt\n\ndef strict_ok(table: pw.Table, name: str) -> bool:\n    return table.schema._dtypes()[name] != dt.INT","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass strict=True when the column is known to be float; integer sums are exact already.","Pin column dtypes in the schema so the choice is visible at the reduce call site."],"tags":["pathway","reducer","sum","configuration"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}