pathwaycom/pathway · error · TypeError
{name} has to be a Table instead of {type(arg)}
Error message
{name} has to be a Table instead of {type(arg)} What it means
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.
Source
Thrown at python/pathway/internals/operator.py:365
self._universe_mapping = defaultdict(Universe)
def __call__(self, **kwargs):
input = as_arg_tuple(kwargs)
input_copy = ArgTuple.empty()
iterated_with_universe_copy = ArgTuple.empty()
# unwrap input and materialize input copy
for name, arg in input.items():
if isinstance(arg, pw.Table):
input_copy[name] = self._copy_input_table(name, arg, unique=False)
elif isinstance(arg, iterate_universe):
iterated_with_universe_copy[name] = self._copy_input_table(
name, arg.table, unique=True
)
input[name] = arg.table
else:
raise TypeError(f"{name} has to be a Table instead of {type(arg)}")
assert all(isinstance(table, pw.Table) for table in input)
# call iteration logic with copied input and sort result by input order
raw_result = self.func_spec.func(**input_copy, **iterated_with_universe_copy)
arg_tuple = as_arg_tuple(raw_result)
result = arg_tuple.process_input(input)
if not iterated_with_universe_copy.is_key_subset_of(result):
raise ValueError(
"not all arguments marked as iterated returned from iteration"
)
for name, table in result.items():
input_table: pw.Table = input[name]
assert isinstance(table, pw.Table)
input_schema = input_table.schema._dtypes()
result_schema = table.schema._dtypes()
if input_schema != result_schema:
raise ValueError(View on GitHub (pinned to fa2f74a464)
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).
Example fix
# before
@pw.table_transformer
def scale(t: pw.Table, factor): # factor: int reaches the operator
...
scale(table, 2)
# after
@pw.table_transformer
def scale(t: pw.Table, factor: float = 2.0):
return t.select(v=pw.this.v * factor)
scale(table) Defensive patterns
Strategy: type-guard
Validate before calling
import pathway as pw
def all_args_are_tables(kwargs: dict) -> bool:
return all(isinstance(v, (pw.Table, pw.iterate_universe)) for v in kwargs.values()) Type guard
import pathway as pw
from typing import TypeGuard
def is_table(v) -> TypeGuard[pw.Table]:
return isinstance(v, pw.Table) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- not all arguments marked as iterated returned from iteration
- output: {result_schema} of the iterated function does not c
- iterated table not marked as 'iterate_universe' changed its
- direction argument of join should be of type asof_join.Direc
- The interval argument of a join should be of a type pathway.
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/8aa9d4d1e6fcb221.
Report an issue: GitHub.