pathwaycom/pathway · error · ValueError

creating a reference to a class_arg table defined for anothe

Error message

creating a reference to a class_arg table defined for another transformer

What it means

In Pathway class transformers (@pw.row_transformer classes), a class_arg attribute (a table defined inside one transformer class) can only be referenced from RowReferences belonging to the same transformer. RowReferenceClassArg.__call__ checks ref._class_arg.transformer != self.transformer and rejects mixing a RowReference from transformer A with a class_arg (pointer method) from transformer B.

Source

Thrown at python/pathway/internals/row_transformer.py:141

            if isinstance(attr, AbstractOutputAttribute)
        }

    def _is_attribute(self, col_name: str) -> bool:
        return col_name in self._attributes

    def _get_attribute(self, col_name: str) -> AbstractAttribute:
        return self._attributes[col_name]

    def _get_class_property(self, name: str) -> Any:
        assert name not in self._attributes
        return inspect.getattr_static(self, name)

    def __set_name__(self, owner, name):
        self.name: str = name

    def __call__(self, ref: RowReference, ptr: Pointer) -> RowReference:  # type: ignore
        if ref._class_arg.transformer != self.transformer:
            raise ValueError(
                "creating a reference to a class_arg table defined for another transformer"
            )

        return ref._with_class_arg(self, ptr)


class ClassArg(metaclass=ClassArgMeta):
    """Base class to inherit from when writing inner classes for class transformers."""

    transformer: RowTransformer  # stub for mypy
    id: Pointer  # stub for mypy

    def pointer_from(self, *args, optional=False) -> Pointer:
        """Pseudo-random hash of its argument. Produces pointer types. Applied value-wise."""
        return ref_scalar(*args, optional=optional)

    def __init_subclass__(
        cls,

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Keep each class_arg inside the transformer whose rows it operates on; duplicate or move the method into the transformer that supplies the RowReference.
  2. If logic must be shared, factor it into a plain function taking the extracted column values, not a class_arg.
  3. Ensure you instantiate/reference the class_arg through the same transformer class (ClassName.method(ref)) that produced ref.

Example fix

# before
@pw.row_transformer
class A:
    class input(pw.ClassArg): ...
    class lookup(pw.ClassArg, id_from=input): ...

@pw.row_transformer
class B:
    class input(pw.ClassArg):
        def enrich(self, ref):
            return A.lookup(ref)  # ref belongs to B -> error

# after
@pw.row_transformer
class B:
    class input(pw.ClassArg): ...
    class lookup(pw.ClassArg, id_from=input): ...  # local lookup

    def enrich(...)  # use B.lookup(ref)
Defensive patterns

Strategy: type-guard

Validate before calling

def same_transformer(ref, class_arg) -> bool:
    return ref._class_arg.transformer is class_arg.transformer

Prevention

When it happens

Trigger: Calling a method defined as class_arg in transformer X on a RowReference that originates from transformer Y, e.g. inside row_transformer methods: other_transformer.table_method(ref) where ref comes from a different transformer's context, or reusing a stored class_arg across transformer instances.

Common situations: Refactoring shared logic between two row transformers and moving a method to the wrong class; passing RowReference objects between transformers as if they were plain rows.

Related errors


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