{"record":{"id":"24ae6b056e54bd15","repo":"pathwaycom/pathway","slug":"pathway-does-not-support-using-reducer-self-name","errorCode":null,"errorMessage":"Pathway does not support using reducer {self.name} 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":234,"sourceCode":"        if context.sort_by is not None:\n            return (context.sort_by.to_column_expression(),)\n        else:\n            return ()\n\n\nclass TupleConvertibleToNDArrayWrappingReducer(TupleWrappingReducer):\n    def return_type(\n        self, arg_types: builtins.list[dt.DType], id_type: dt.DType\n    ) -> dt.DType:\n        arg_type = arg_types[0]\n        if self._skip_nones:\n            arg_type = dt.unoptionalize(arg_type)\n        if builtins.any(\n            dt.dtype_issubclass(arg_type, dtype)\n            for dtype in [dt.FLOAT, dt.ANY_ARRAY, dt.ANY_TUPLE]\n        ):\n            return dt.List(arg_type)\n        raise TypeError(\n            f\"Pathway does not support using reducer {self.name}\"\n            + f\" on column of type {arg_type}.\\n\"\n        )\n\n\nclass StatefulManyReducer(Reducer):\n    name = \"stateful_many\"\n    combine_many: api.CombineMany\n\n    def __init__(self, combine_many: api.CombineMany):\n        self.combine_many = combine_many\n\n    def return_type(self, arg_types: list[dt.DType], id_type: dt.DType) -> dt.DType:\n        return dt.ANY\n\n    def engine_reducer(self, arg_types: list[dt.DType]) -> api.Reducer:\n        return api.Reducer.stateful_many(self.combine_many)\n","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/reducers.py#L216-L252","documentation":"Tuple-producing reducers such as pathway.reducers.tuple (and ndarray variants) build a dt.List of the argument type, which only makes sense when the column is float-like, array-like, or tuple-like. In TupleConvertibleToNDArrayWrappingReducer.return_type, any other dtype (str, bool, Pointer, json...) fails the dtype_issubclass check against FLOAT/ANY_ARRAY/ANY_TUPLE and raises this TypeError.","triggerScenarios":"table.reduce(vals=pw.reducers.tuple(pw.this.name)) where name is a str column; or the numpy-oriented reducers (np.values etc.) applied to non-numeric columns. _skip_nones transparently unoptionalizes Optional[...] first, so Optional[str] also fails.","commonSituations":"Collecting string values per group with pw.reducers.tuple instead of a dedicated string aggregation; feeding json or pointer columns into tuple/np-style reducers.","solutions":["Verify the column dtype is float/int/array/tuple before using these reducers; cast if numeric-like data arrived as str.","For collecting arbitrary values (including strings), write a custom reducer with pw.custom_reducers.red_state_many or use a different aggregation approach.","If the column is Optional[numeric] and _skip_nones semantics matter, ensure the underlying type after unoptionalize is numeric/array/tuple."],"exampleFix":"# before\nagg = t.groupby(t.key).reduce(names=pw.reducers.tuple(t.name))  # name: str\n\n# after\ncollect_names = pw.custom_reducers.red_state_many(\n    lambda state, name: (state or []) + [name]\n)\nagg = t.groupby(t.key).reduce(names=collect_names(t.name))","handlingStrategy":"validation","validationCode":"from pathway.internals import dtype as dt\n\ndef column_accepts_tuple_reducer(dtype) -> bool:\n    return any(\n        dt.dtype_issubclass(dtype, d) for d in (dt.FLOAT, dt.ANY_ARRAY, dt.ANY_TUPLE)\n    )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve pw.reducers.tuple for numeric/array/tuple columns; use custom reducers for strings.","Un-Optional columns (skip_nones) only when the payload type itself is supported."],"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"}