pathwaycom/pathway · error · ValueError

Expected a ColumnReference, found a string. Did you mean thi

Error message

Expected a ColumnReference, found a string. Did you mean this.{arg} instead of {repr(arg)}?

What it means

Table.reduce()'s argument preprocessor requires every positional argument to be a ColumnReference with a resolvable name (expr.smart_name). When a bare string is passed, it raises this hint because the most common intent was referencing a column via table attribute access (e.g. this.col_name), not passing a string literal.

Source

Thrown at python/pathway/internals/arg_handlers.py:184

        if "right_exactly_once" in kwargs:
            processed_kwargs["right_exactly_once"] = kwargs.pop("right_exactly_once")

        if kwargs:
            raise ValueError(
                "Join received extra kwargs.\n"
                + "You probably want to use TableLike.join(...).select(**kwargs) to compute output columns."
            )
        return (self, other, *on), processed_kwargs

    return handler


def reduce_args_handler(self, *args, **kwargs):
    for arg in args:
        if expr.smart_name(arg) is None:
            if isinstance(arg, str):
                raise ValueError(
                    f"Expected a ColumnReference, found a string. Did you mean this.{arg} instead of {repr(arg)}?"
                )
            else:
                raise ValueError(
                    "In reduce() all positional arguments have to be a ColumnReference."
                )
    return (self, *args), kwargs


def select_args_handler(self, *args, **kwargs):
    for arg in args:
        if not isinstance(arg, expr.ColumnReference):
            if isinstance(arg, str):
                raise ValueError(
                    f"Expected a ColumnReference, found a string. Did you mean this.{arg} instead of {repr(arg)}?"
                )
            else:
                raise ValueError(

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Replace the string with a ColumnReference: table.reduce(t.key, sum_price=pw.reducers.sum(t.price)).
  2. If referencing the table inside a method, use self.key or this.key rather than the literal name.

Example fix

# before
t.groupby(t.owner).reduce("owner", total=pw.reducers.sum(t.price))

# after
t.groupby(t.owner).reduce(t.owner, total=pw.reducers.sum(t.price))
Defensive patterns

Strategy: type-guard

Validate before calling

args_ok = all(hasattr(a, '_column') and hasattr(a, '_table') for a in args)
assert args_ok, 'positional args to reduce() must be column references like t.col'

Type guard

import pathway.internals.expression as expr

def all_column_refs(args) -> bool:
    return all(isinstance(a, expr.ColumnReference) for a in args)

Prevention

When it happens

Trigger: Calling table.reduce("price", sum_price=pw.reducers.sum(t.price)) or passing a column name string as a positional arg to keep that column in the output.

Common situations: Developers used to pandas agg/reset_index semantics where column names are strings; attempting to include a column by name in reduce output.

Related errors


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