{"record":{"id":"ef9456c54cdac79e","repo":"pathwaycom/pathway","slug":"name-r-is-a-method-name-it-is-discouraged-to-us","errorCode":null,"errorMessage":"{name!r} is a method name. It is discouraged to use it as a column name. If you really want to use it, use [{name!r}].","messagePattern":"(.+?) is a method name\\. It is discouraged to use it as a column name\\. If you really want to use it, use \\[(.+?)\\]\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/table_slice.py","lineNumber":71,"sourceCode":"\n    @overload\n    def __getitem__(self, args: list[str | ColumnReference]) -> TableSlice: ...\n\n    @trace_user_frame\n    def __getitem__(\n        self, arg: str | ColumnReference | list[str | ColumnReference]\n    ) -> ColumnReference | TableSlice:\n        if isinstance(arg, (ColumnReference, str)):\n            return self._mapping[self._normalize(arg)]\n        else:\n            return TableSlice({self._normalize(k): self[k] for k in arg}, self._table)\n\n    @trace_user_frame\n    def __getattr__(self, name: str) -> ColumnReference:\n        from pathway.internals import Table\n\n        if hasattr(Table, name) and name != \"id\":\n            raise ValueError(\n                f\"{name!r} is a method name. It is discouraged to use it as a column\"\n                + f\" name. If you really want to use it, use [{name!r}].\"\n            )\n        if name not in self._mapping:\n            raise AttributeError(f\"Column name {name!r} not found in {self!r}.\")\n        return self._mapping[name]\n\n    @trace_user_frame\n    @check_arg_types\n    def without(self, *cols: str | ColumnReference) -> TableSlice:\n        mapping = self._mapping.copy()\n        for col in cols:\n            colname = self._normalize(col)\n            if colname not in mapping:\n                raise KeyError(f\"Column name {repr(colname)} not found in a {self}.\")\n            mapping.pop(colname)\n        return TableSlice(mapping, self._table)\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/table_slice.py#L53-L89","documentation":"Raised by TableSlice.__getattr__ (the pw.this proxy) when an attribute access matches a Table method name. Pathway reserves method names on the this-proxy; to reference a column that shadows a method you must use item access (['name']) which bypasses __getattr__. Only 'id' is exempted.","triggerScenarios":"Accessing pw.this.filter, pw.this.concat, pw.this.rename, etc. where a column of that name exists — attribute access is interpreted as method-name collision and rejected; e.g. a column literally named 'filter' or 'update'.","commonSituations":"Schemas containing columns named after Table methods ('filter', 'select', 'join', 'sort', 'update'); loading CSVs/JSON with such header names; code generation that emits attribute-style column access.","solutions":["Use item access: pw.this['filter'] or table['filter'] instead of pw.this.filter","Prefer renaming such columns at ingestion: schema field named differently, or rename immediately after input","Audit schemas for Table method names (hasattr(pw.Table, name)) and rename collisions","Configure the connector to rename/skip those columns when reading"],"exampleFix":"# before\nt2 = t.select(pw.this.filter)  # 'filter' is a Table method -> ValueError\n\n# after\nt2 = t.select(pw.this['filter'])","handlingStrategy":"validation","validationCode":"import pathway as pw\n\ndef collides_with_method(name: str) -> bool:\n    return hasattr(pw.Table, name) and name != 'id'\n\n# use t[name] / pw.this[name] for any column where this is True","typeGuard":"def safe_attr_access(name: str) -> bool:\n    import pathway as pw\n    return not (hasattr(pw.Table, name) and name != 'id')","tryCatchPattern":"try:\n    ref = getattr(pw.this, name)\nexcept ValueError as e:\n    if 'method name' in str(e):\n        ref = pw.this[name]","preventionTips":["Always use item access pw.this['col'] for columns named like Table methods","Rename method-named columns at ingestion","Lint incoming schemas against dir(pw.Table)"],"tags":["pathway","column-name","table-slice","api-collision"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}