pathwaycom/pathway · error · ValueError
{name} is a method name. It is discouraged to use it as a co
Error message
{name} is a method name. It is discouraged to use it as a column name. If you really want to use it, use pw.this['{name}']. What it means
Raised by ThisMetaclass.__getattr__ when an attribute accessed on pw.this collides with a method name of the Table class (anything other than the special-cased 'id'). Pathway blocks pw.this.method_name because attribute access is reserved for column references, and method names would shadow real columns; it points you to the string-key form pw.this['name'].
Source
Thrown at python/pathway/internals/thisclass.py:37
class ThisMetaclass(type):
@trace_user_frame
def __getattr__(self, name: str) -> expr.ColumnReference:
if name.startswith("__"):
raise AttributeError
# below a workaround so the doctest is actually run by pytest --doctest-modules
# pytest tries to be smart and captures metaclasses that overload all getattrs
if name == "pytest_mock_example_attribute_that_shouldnt_exist":
raise AttributeError
from pathway.internals.table import Table
# special treatment for 'id' column is caused by the fact that
# Table class has id method
if hasattr(Table, name) and name != "id":
raise ValueError(
f"{name} is a method name. It is discouraged to use it as a column"
+ f" name. If you really want to use it, use pw.this['{name}']."
)
return self._get_colref_by_name(name, AttributeError)
def _get_colref_by_name(self, name: str, exception_type) -> expr.ColumnReference:
return expr.ColumnReference(_table=self, _column=None, _name=name) # type: ignore
# TODO:
# create an abstract base class for Table and ThisMetaclass (AbstractTable?)
# have ThisMetaclass explicitly implement all the methods of AbstractTable like:
def rename(self, *args, **kwargs):
return self._create_mock("rename", args, kwargs)
def without(self, *args, **kwargs):
return self._create_mock("without", args, kwargs)
View on GitHub (pinned to fa2f74a464)
Solutions
- Use the item-access form as the message suggests: pw.this['filter'] instead of pw.this.filter
- Rename the offending column early: table.rename({'filter': 'filter_value'}) or via csv_settings/input schema aliasing, then use normal attribute access
- Declare the column name explicitly in the input schema with a Python-safe alias and map it in the connector
Example fix
# before
out = table.select(pw.this.filter) # ValueError: 'filter' is a method name
# after
out = table.select(pw.this["filter"])
# or
table = table.rename({"filter": "filter_col"})
out = table.select(pw.this.filter_col) Defensive patterns
Strategy: validation
Validate before calling
import pathway as pw
from pathway.internals.table import Table
RESERVED = {n for n in dir(Table) if not n.startswith("_")} | {"id"}
def safe_col_expr(name: str):
"""Return a column reference safe against Table-method collisions."""
return pw.this[name] # item access never collides
# check incoming schema
clashes = [c for c in column_names if c in RESERVED] Type guard
def needs_bracket_access(name: str) -> bool:
from pathway.internals.table import Table
return hasattr(Table, name) and name != "id" Try / catch
try:
ref = getattr(pw.this, name)
except ValueError:
ref = pw.this[name] Prevention
- Use pw.this['name'] whenever a column name could collide with Table methods
- Scan incoming column names against dir(Table) once at connector setup
- Rename clashing columns at ingestion time
When it happens
Trigger: Accessing pw.this.<name> where <name> is a Table method such as 'filter', 'select', 'rename', 'update', 'with_id', 'sort', etc., e.g. pw.this.filter inside select(); having a data column literally named 'filter', 'select', or any Table method.
Common situations: Ingesting datasets whose column names clash with Table API names (e.g. a column named 'filter' or 'update'); writing pw.this.rename or pw.this.filter in expression contexts.
Related errors
- TableSlice expects {repr(arg.name)} or this.{arg.name} argum
- You cannot iterate over mock class.
- You cannot instantiate `this` class.
- Usage of {base_this} not supported here.
- Failed to install dependencies
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/47d0f0007c270227.
Report an issue: GitHub.