{"record":{"id":"47d0f0007c270227","repo":"pathwaycom/pathway","slug":"name-is-a-method-name-it-is-discouraged-to-use","errorCode":null,"errorMessage":"{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}'].","messagePattern":"(.+?) is a method name\\. It is discouraged to use it as a column name\\. If you really want to use it, use pw\\.this\\['(.+?)'\\]\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/thisclass.py","lineNumber":37,"sourceCode":"\n\nclass ThisMetaclass(type):\n    @trace_user_frame\n    def __getattr__(self, name: str) -> expr.ColumnReference:\n        if name.startswith(\"__\"):\n            raise AttributeError\n\n        # below a workaround so the doctest is actually run by pytest --doctest-modules\n        # pytest tries to be smart and captures metaclasses that overload all getattrs\n        if name == \"pytest_mock_example_attribute_that_shouldnt_exist\":\n            raise AttributeError\n\n        from pathway.internals.table import Table\n\n        # special treatment for 'id' column is caused by the fact that\n        # Table class has id method\n        if hasattr(Table, name) and name != \"id\":\n            raise ValueError(\n                f\"{name} is a method name. It is discouraged to use it as a column\"\n                + f\" name. If you really want to use it, use pw.this['{name}'].\"\n            )\n        return self._get_colref_by_name(name, AttributeError)\n\n    def _get_colref_by_name(self, name: str, exception_type) -> expr.ColumnReference:\n        return expr.ColumnReference(_table=self, _column=None, _name=name)  # type: ignore\n\n    # TODO:\n    # create an abstract base class for Table and ThisMetaclass (AbstractTable?)\n    # have ThisMetaclass explicitly implement all the methods of AbstractTable like:\n\n    def rename(self, *args, **kwargs):\n        return self._create_mock(\"rename\", args, kwargs)\n\n    def without(self, *args, **kwargs):\n        return self._create_mock(\"without\", args, kwargs)\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/thisclass.py#L19-L55","documentation":"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'].","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nout = table.select(pw.this.filter)  # ValueError: 'filter' is a method name\n\n# after\nout = table.select(pw.this[\"filter\"])\n# or\ntable = table.rename({\"filter\": \"filter_col\"})\nout = table.select(pw.this.filter_col)","handlingStrategy":"validation","validationCode":"import pathway as pw\nfrom pathway.internals.table import Table\n\nRESERVED = {n for n in dir(Table) if not n.startswith(\"_\")} | {\"id\"}\n\ndef safe_col_expr(name: str):\n    \"\"\"Return a column reference safe against Table-method collisions.\"\"\"\n    return pw.this[name]  # item access never collides\n\n# check incoming schema\nclashes = [c for c in column_names if c in RESERVED]","typeGuard":"def needs_bracket_access(name: str) -> bool:\n    from pathway.internals.table import Table\n    return hasattr(Table, name) and name != \"id\"","tryCatchPattern":"try:\n    ref = getattr(pw.this, name)\nexcept ValueError:\n    ref = pw.this[name]","preventionTips":["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"],"tags":["pathway","this","column-name-clash","getattr"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}