{"record":{"id":"8aa9d4d1e6fcb221","repo":"pathwaycom/pathway","slug":"name-has-to-be-a-table-instead-of-type-arg","errorCode":null,"errorMessage":"{name} has to be a Table instead of {type(arg)}","messagePattern":"(.+?) has to be a Table instead of (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/operator.py","lineNumber":365,"sourceCode":"        self._universe_mapping = defaultdict(Universe)\n\n    def __call__(self, **kwargs):\n        input = as_arg_tuple(kwargs)\n\n        input_copy = ArgTuple.empty()\n        iterated_with_universe_copy = ArgTuple.empty()\n\n        # unwrap input and materialize input copy\n        for name, arg in input.items():\n            if isinstance(arg, pw.Table):\n                input_copy[name] = self._copy_input_table(name, arg, unique=False)\n            elif isinstance(arg, iterate_universe):\n                iterated_with_universe_copy[name] = self._copy_input_table(\n                    name, arg.table, unique=True\n                )\n                input[name] = arg.table\n            else:\n                raise TypeError(f\"{name} has to be a Table instead of {type(arg)}\")\n\n        assert all(isinstance(table, pw.Table) for table in input)\n\n        # call iteration logic with copied input and sort result by input order\n        raw_result = self.func_spec.func(**input_copy, **iterated_with_universe_copy)\n        arg_tuple = as_arg_tuple(raw_result)\n        result = arg_tuple.process_input(input)\n        if not iterated_with_universe_copy.is_key_subset_of(result):\n            raise ValueError(\n                \"not all arguments marked as iterated returned from iteration\"\n            )\n        for name, table in result.items():\n            input_table: pw.Table = input[name]\n            assert isinstance(table, pw.Table)\n            input_schema = input_table.schema._dtypes()\n            result_schema = table.schema._dtypes()\n            if input_schema != result_schema:\n                raise ValueError(","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/operator.py#L347-L383","documentation":"Inside a @pw.table_transformer decorated iteration function (transformer used with pw.iterate / transform_iterate), every argument must be either a pw.Table or a value wrapped in pw.iterate_universe. The operator machinery copies each input table before invoking the iteration logic; anything else (an int, a DataFrame, None) cannot be processed as a table and raises this TypeError.","triggerScenarios":"Defining a @pw.table_transformer function whose parameter is not typed as pw.Table and calling it (directly or via pw.iterate) with a non-Table value, e.g. def my_transformer(t: pw.Table, factor: int) where factor is passed positionally into the iteration machinery, or passing a pandas DataFrame instead of a pw.Table.","commonSituations":"Mixing pandas/polars DataFrames with Pathway tables, passing config scalars as transformer arguments instead of closing over them, or passing pw.this.column (a ColumnReference) where a whole table is required.","solutions":["Pass only pw.Table objects (or pw.iterate_universe(pw.Table) wrappers) as transformer arguments; capture constants in a closure or functools.partial instead.","Convert pandas DataFrames with pw.debug.table_from_pandas() or io via pw.io.csv.read before calling the transformer.","If you meant a table carrying its universe through iteration, wrap it: pw.iterate_universe(table)."],"exampleFix":"# before\n@pw.table_transformer\ndef scale(t: pw.Table, factor):  # factor: int reaches the operator\n    ...\nscale(table, 2)\n\n# after\n@pw.table_transformer\ndef scale(t: pw.Table, factor: float = 2.0):\n    return t.select(v=pw.this.v * factor)\nscale(table)","handlingStrategy":"type-guard","validationCode":"import pathway as pw\n\ndef all_args_are_tables(kwargs: dict) -> bool:\n    return all(isinstance(v, (pw.Table, pw.iterate_universe)) for v in kwargs.values())","typeGuard":"import pathway as pw\nfrom typing import TypeGuard\n\ndef is_table(v) -> TypeGuard[pw.Table]:\n    return isinstance(v, pw.Table)","tryCatchPattern":null,"preventionTips":["Annotate every @pw.table_transformer parameter as pw.Table so static checkers catch misuse.","Convert pandas/polars inputs with the pw.io or debug helpers before entering transformer code."],"tags":["pathway","table-transformer","iteration","type-error"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}