{"record":{"id":"b186750a799338d1","repo":"pathwaycom/pathway","slug":"tableslice-expects-repr-arg-name-or-this-arg-n","errorCode":null,"errorMessage":"TableSlice expects {repr(arg.name)} or this.{arg.name} argument as column reference.","messagePattern":"TableSlice expects (.+?) or this\\.(.+?) argument as column reference\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/table_slice.py","lineNumber":143,"sourceCode":"        )\n\n    @trace_user_frame\n    def ix_ref(self, *args, optional: bool = False, context=None) -> TableSlice:\n        new_table = self._table.ix_ref(*args, optional=optional, context=context)\n        return TableSlice(\n            {name: new_table[colref._name] for name, colref in self._mapping.items()},\n            new_table,\n        )\n\n    @property\n    def slice(self):\n        return self\n\n    def _normalize(self, arg: str | ColumnReference):\n        if isinstance(arg, ColumnReference):\n            if isinstance(arg.table, ThisMetaclass):\n                if arg.table != this:\n                    raise ValueError(\n                        f\"TableSlice expects {repr(arg.name)} or this.{arg.name} argument as column reference.\"\n                    )\n            else:\n                if arg.table != self._table:\n                    raise ValueError(\n                        \"TableSlice method arguments should refer to table of which the slice was created.\"\n                    )\n            return arg.name\n        else:\n            return arg\n","sourceCodeStart":125,"sourceCodeEnd":154,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/table_slice.py#L125-L154","documentation":"Raised by TableSlice._normalize() when a ColumnReference argument is bound to a 'this'-like object (a ThisMetaclass instance) that is not the global pathway.this. Slices accept plain column names or references of the form this.col (or this['col']) only; any other this-variant reference is rejected.","triggerScenarios":"Passing a column reference built from a custom/joining this object (e.g. this_from a join context, async ingest context this, or a subclass of ThisMetaclass) into TableSlice methods such as without(), rename(), or __getitem__; passing table.this.col where table.this is not the global this.","commonSituations":"Inside join contexts where pathway exposes a different this for the left/right side; using a ThisMetaclass subclass produced by table slicing machinery; code copied from a join example into plain slice operations.","solutions":["Pass the bare column name string instead of a foreign this reference: without('col') rather than without(other_this.col)","Use the global reference form: pathway.this.col or pathway.this['col']","Inside a join, first materialize the reference against the correct side (table.col) or wait until you are outside the join context"],"exampleFix":"# before\nslice.without(result.this.col)  # ValueError: expects 'col' or this.col\n\n# after\nslice.without(\"col\")\n# or\nimport pathway as pw\nslice.without(pw.this.col)","handlingStrategy":"type-guard","validationCode":"import pathway as pw\n\ndef normalize_ref(ref):\n    \"\"\"Pass strings or global pw.this refs only.\"\"\"\n    if isinstance(ref, pw.ColumnReference):\n        assert ref.table is pw.this or isinstance(ref, str), ref\n    return ref","typeGuard":"def is_global_this_ref(ref) -> bool:\n    import pathway as pw\n    return isinstance(ref, str) or (\n        getattr(ref, \"table\", None) is pw.this\n    )","tryCatchPattern":"try:\n    slice2 = table_slice.without(ref)\nexcept ValueError as e:\n    if \"expects\" in str(e):\n        slice2 = table_slice.without(ref.name)  # fall back to bare name\n    else:\n        raise","preventionTips":["Prefer plain column-name strings when calling TableSlice methods","Never persist this-references from join contexts into later calls","Standardize on pw.this.col / pw.this['col'] inside expressions"],"tags":["pathway","table-slice","column-reference","this"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}