pathwaycom/pathway · error · AttributeError

Column name {name!r} not found in {self!r}.

Error message

Column name {name!r} not found in {self!r}.

What it means

Raised by TableSlice.__getattr__ when the accessed attribute is neither a Table method name nor a column present in the slice's mapping. It is a plain AttributeError raised from the pw.this proxy, meaning the requested column simply does not exist on that table/slice.

Source

Thrown at python/pathway/internals/table_slice.py:76

    def __getitem__(
        self, arg: str | ColumnReference | list[str | ColumnReference]
    ) -> ColumnReference | TableSlice:
        if isinstance(arg, (ColumnReference, str)):
            return self._mapping[self._normalize(arg)]
        else:
            return TableSlice({self._normalize(k): self[k] for k in arg}, self._table)

    @trace_user_frame
    def __getattr__(self, name: str) -> ColumnReference:
        from pathway.internals import Table

        if hasattr(Table, name) and name != "id":
            raise ValueError(
                f"{name!r} is a method name. It is discouraged to use it as a column"
                + f" name. If you really want to use it, use [{name!r}]."
            )
        if name not in self._mapping:
            raise AttributeError(f"Column name {name!r} not found in {self!r}.")
        return self._mapping[name]

    @trace_user_frame
    @check_arg_types
    def without(self, *cols: str | ColumnReference) -> TableSlice:
        mapping = self._mapping.copy()
        for col in cols:
            colname = self._normalize(col)
            if colname not in mapping:
                raise KeyError(f"Column name {repr(colname)} not found in a {self}.")
            mapping.pop(colname)
        return TableSlice(mapping, self._table)

    @trace_user_frame
    @check_arg_types
    def rename(
        self,
        rename_dict: dict[str | ColumnReference, str | ColumnReference],

View on GitHub (pinned to fa2f74a464)

Solutions

  1. List available columns: print(t.column_names()) and fix the name
  2. Check whether an earlier select/without removed the column; reorder or re-add it
  3. Ensure you use the correct table's proxy (pw.this vs pw.left/pw.right in joins)
  4. In tests, assert required columns exist before building expressions: assert 'col' in t.keys()

Example fix

# before
t2 = t.select(pw.this.usr_name)  # column is 'user_name'

# after
t2 = t.select(pw.this.user_name)
Defensive patterns

Strategy: validation

Validate before calling

def column_exists(t, name: str) -> bool:
    return name in t.keys()

# assert column_exists(t, 'user_name') before building expressions

Type guard

def has_columns(t, *names) -> bool:
    return all(n in t.keys() for n in names)

Try / catch

try:
    ref = getattr(pw.this, name)
except AttributeError as e:
    if 'not found' in str(e):
        raise KeyError(f'{name} not in {t.column_names()}') from e

Prevention

When it happens

Trigger: pw.this.typo_col inside select/filter/with_columns; accessing a column dropped by an earlier select/without; using a slice that was constructed from a subset of columns.

Common situations: Typos in column names; schema drift after connector changes; referencing columns removed earlier in the chain; using the wrong pw.this from another table in a multi-table pipeline.

Related errors


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