pathwaycom/pathway · error · ValueError
not all arguments marked as iterated returned from iteration
Error message
not all arguments marked as iterated returned from iteration
What it means
In a @pw.table_transformer used with iteration, arguments marked with pw.iterate_universe must also appear in the transformer's return value: the engine tracks their universes across iteration steps. If the function returns a dict/tuple of tables that omits an argument declared with pw.iterate_universe, this ValueError is raised because the iteration contract is broken.
Source
Thrown at python/pathway/internals/operator.py:374
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(
f"output: {result_schema} of the iterated function does not correspond to the input: {input_schema}" # noqa
)
table._sort_columns_by_other(input_table)
# designate iterated arguments
self.iterated_with_universe = input.intersect_keys(iterated_with_universe_copy)
self.iterated = input.intersect_keys(result).subtract_keys(
iterated_with_universe_copy
)View on GitHub (pinned to fa2f74a464)
Solutions
- Return every argument that was passed as pw.iterate_universe: if you call transformer(a=pw.iterate_universe(t1), b=t2), the result must contain key 'a'.
- Keep the returned dict keys identical to the argument names of the transformer function.
- If the table no longer needs its universe carried through iteration, drop pw.iterate_universe and pass it as a plain argument.
Example fix
# before
@pw.table_transformer
def step(t: pw.Table, carry: pw.Table) -> dict:
return {"t": t.select(...)} # 'carry' was iterate_universe, missing
result = pw.iterate(step, t=t, carry=pw.iterate_universe(carry))
# after
@pw.table_transformer
def step(t: pw.Table, carry: pw.Table) -> dict:
return {"t": t.select(...), "carry": carry} Defensive patterns
Strategy: validation
Validate before calling
import pathway as pw
def iterate_args_satisfied(func_kwargs, result_dict):
required = {n for n, v in func_kwargs.items() if isinstance(v, pw.iterate_universe)}
return required <= set(result_dict.keys()) Prevention
- Return the full input dict pattern: {**inputs, 'result': new_table} and update only what changes.
- Keep iterate_universe argument names and returned dict keys identical.
When it happens
Trigger: A transformer like def f(t: pw.Table) -> pw.Table used inside pw.iterate where the original call passed pw.iterate_universe(extra_table) but the returned dict does not include a table under the key 'extra_table'; also returning fewer tables than the iterate_universe-marked inputs.
Common situations: Refactoring a transformer to return only a subset of its inputs, renaming returned dict keys so they no longer match argument names, or misunderstanding that iterate_universe args must flow through every iteration step.
Related errors
- iterated table not marked as 'iterate_universe' changed its
- {name} has to be a Table instead of {type(arg)}
- output: {result_schema} of the iterated function does not c
- transformer has no attribute `{table_name}`
- You cannot use {dep.to_column_expression()} in this context.
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/7453bea5449a2812.
Report an issue: GitHub.