pathwaycom/pathway · error · ValueError

Universe of the argument of Table.update_cells() needs to be

Error message

Universe of the argument of Table.update_cells() needs to be a subset of the universe of the updated table.
Consider using Table.promise_is_subset_of() to assert this.
(However, untrue assertion might result in runtime errors.)

What it means

Raised by Table._update_cells() when other's universe is not provably a subset of self's universe. update_cells writes values onto existing rows of self, so every row id in `other` must exist in self; otherwise some updates would target non-existent rows. Pathway requires an explicit assertion if the solver cannot prove the subset relation.

Source

Thrown at python/pathway/internals/table.py:1761

        schema = {}
        for key in other.keys():
            schema[key] = _types_lca_with_error(
                self.schema._dtypes()[key],
                other.schema._dtypes()[key],
                function_name="an update_cells",
                pointers=False,
            )

        return Table._update_cells(
            self.cast_to_types(**schema), other.cast_to_types(**schema)
        )

    @trace_user_frame
    @contextualized_operator
    @check_arg_types
    def _update_cells(self, other: Table) -> Table:
        if not other._universe.is_subset_of(self._universe):
            raise ValueError(
                "Universe of the argument of Table.update_cells() needs to be "
                + "a subset of the universe of the updated table.\n"
                + "Consider using Table.promise_is_subset_of() to assert this.\n"
                + "(However, untrue assertion might result in runtime errors.)"
            )
        context = clmn.UpdateCellsContext(
            left=self._id_column,
            right=other._id_column,
            updates={name: other._columns[name] for name in other.keys()},
        )
        return self._table_with_context(context)

    @trace_user_frame
    @check_arg_types
    def update_rows(self, other: Table[TSchema]) -> Table[TSchema]:
        """Updates rows of `self`, breaking ties in favor for the rows in `other`.

        Semantics:

View on GitHub (pinned to fa2f74a464)

Solutions

  1. If the subset relation genuinely holds, assert it: pw.universes.promise_is_subset_of(t2, t1) before calling t1.update_cells(t2)
  2. Otherwise restrict the argument: t1.update_cells(t2.filter(t2.id.is_in(...))) or intersect universes first
  3. If rows may be new, use table_static_changed_rows-free composition like update_rows or concat-with-new-ids instead
  4. Sanity-check id overlap in tests with pw.debug.compute_and_print before asserting

Example fix

# before
t3 = t1.update_cells(t2)  # ValueError: universe not a subset

# after (only if t2's keys really are a subset of t1's)
pw.universes.promise_is_subset_of(t2, t1)
t3 = t1.update_cells(t2)
Defensive patterns

Strategy: validation

Validate before calling

# Only promise when the subset relation truly holds
import pathway as pw

def update_cells_subset(t1, t2):
    pw.universes.promise_is_subset_of(t2, t1)
    return t1.update_cells(t2)

Try / catch

try:
    t3 = t1.update_cells(t2)
except ValueError as e:
    if 'needs to be a subset' in str(e):
        pw.universes.promise_is_subset_of(t2, t1)
        t3 = t1.update_cells(t2)

Prevention

When it happens

Trigger: t1.update_cells(t2) where t2 may contain ids not present in t1 (t2 built from a different source, or filtered differently); universe solver says other._universe.is_subset_of(self._universe) is False.

Common situations: Applying updates from a wider/parallel source table; updates arriving for keys that were filtered out of the base table; forgetting that promise_is_subset_of is required when ids come from separate connectors.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/5e682eb0a4304318. Report an issue: GitHub.