{"record":{"id":"4b203b59d2679823","repo":"pathwaycom/pathway","slug":"pathway-does-not-support-using-reducer-self-on-c","errorCode":null,"errorMessage":"Pathway does not support using reducer {self} on column of type {arg_type}.\n","messagePattern":"Pathway does not support using reducer (.+?) on column of type (.+?)\\.\n","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/reducers.py","lineNumber":120,"sourceCode":"        warnings.warn(\n            f\"{self.name} reducer uses processing time to choose elements\"\n            + \" while windowby uses data time to assign entries to windows.\"\n            + \" Maybe it is not the behavior you want. To choose elements according\"\n            + f\" to their data time, you may use {self.alternative} reducer.\",\n            stacklevel=12,\n        )\n\n\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):","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/reducers.py#L102-L138","documentation":"The sum reducer (pathway.reducers.sum) only accepts columns whose dtype is a float subtype or an array subtype (checked via dt.dtype_issubclass against dt.FLOAT and ANY_ARRAY; ints are handled separately in engine_reducer_unary). If the aggregated column is e.g. str, bool, Pointer, or a duration/complex type, return_type_unary raises this TypeError at expression-building time.","triggerScenarios":"table.reduce(s=pw.reducers.sum(t.col)) where col has dtype str, bool, Optional[str], json, or any non-numeric non-array type; equivalently table.groupby(...).reduce(sum=pw.reducers.sum(...)) on a text column.","commonSituations":"CSV columns auto-typed as str that hold numbers ('price' parsed as string); aggregating a json column; trying to sum boolean flags.","solutions":["Cast the column to numeric before reducing: pw.reducers.sum(pw.this.col.astype(float)) (or int, which selects INT_SUM).","Fix ingestion so the column is parsed as int/float (e.g. input_format / schema with dtype=float in pw.io.csv.read or pw.io.jsonl.read).","If the column is genuinely non-numeric, use a different reducer (tuple, count, min/max on comparable types) — summing text is not supported."],"exampleFix":"# before\nagg = table.groupby(pw.this.key).reduce(total=pw.reducers.sum(pw.this.price))  # price is str\n\n# after\nagg = table.groupby(pw.this.key).reduce(total=pw.reducers.sum(pw.this.price.astype(float)))","handlingStrategy":"validation","validationCode":"import pathway as pw\nfrom pathway.internals import dtype as dt\n\ndef column_is_summable(table: pw.Table, name: str) -> bool:\n    d = table.schema._dtypes()[name]\n    return dt.dtype_issubclass(d, dt.FLOAT) or dt.dtype_issubclass(d, dt.ANY_ARRAY) or d == dt.INT","typeGuard":"import pathway as pw\nfrom pathway.internals import dtype as dt\n\ndef is_numeric_column(table: pw.Table, name: str) -> bool:\n    d = table.schema._dtypes()[name]\n    return dt.dtype_issubclass(d, dt.FLOAT) or d == dt.INT","tryCatchPattern":null,"preventionTips":["Declare numeric dtypes explicitly in read schemas instead of relying on auto-detection.","Cast with .astype(float) when summing columns that connectors may deliver as strings."],"tags":["pathway","reducer","dtype","aggregation","type-mismatch"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}