{"record":{"id":"eb9058964278d3b2","repo":"pathwaycom/pathway","slug":"usage-of-base-this-not-supported-here","errorCode":null,"errorMessage":"Usage of {base_this} not supported here.","messagePattern":"Usage of (.+?) not supported here\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/thisclass.py","lineNumber":137,"sourceCode":"        raise TypeError(\"You cannot instantiate `this` class.\")\n\n    def pointer_from(\n        self, *args: Any, optional=False, instance: expr.ColumnReference | None = None\n    ):\n        return expr.PointerExpression(self, *args, optional=optional, instance=instance)  # type: ignore[arg-type]\n\n    def _base_this(self) -> ThisMetaclass:\n        raise NotImplementedError\n\n    def _eval_table(self, table: Joinable) -> Joinable:\n        raise NotImplementedError\n\n    def _eval_substitution(\n        self, substitution: dict[ThisMetaclass, Joinable]\n    ) -> Joinable:\n        base_this: ThisMetaclass = self._base_this()\n        if base_this not in substitution:\n            raise TypeError(f\"Usage of {base_this} not supported here.\")\n        return self._eval_table(substitution[base_this])\n\n    def _create_mock(self, name, args, kwargs) -> ThisMetaclass:\n        raise NotImplementedError\n\n    def _delayed_op(self, op, *, expression=None, name=None, qualname=None):\n        raise NotImplementedError\n\n    def _delay_depth(self):\n        raise NotImplementedError\n\n    def _expression(self):\n        raise NotImplementedError\n\n    def _with_new_expression(self, expression):\n        raise NotImplementedError\n\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/thisclass.py#L119-L155","documentation":"Raised by ThisMetaclass._eval_substitution() when a this-variant proxy is evaluated in a context that provides no substitution table for it. Pathway resolves this-like references against a context table; if the concrete this (e.g. the base this of a join side or an io context's this) is not registered in the current substitution map, usage of it is unsupported there and a TypeError names the offending this.","triggerScenarios":"Using the left/right this of a join (table_left.this / table_right.this) outside the expression context that defines it; keeping references produced inside a join or async connect context and reusing them later on another table; using pathway.this inside a custom expression evaluated where only a specific table was substituted.","commonSituations":"Storing column references from join contexts in variables and reusing them after the join finished; refactors that move join-side expressions into helper functions called outside the join; mixing this objects between different tables in helper utilities.","solutions":["Rebuild the reference against a concrete table instead of the stale this: use table.col on the actual table object","Keep join/this-referencing expressions inside the context that created them; pass plain column names to helper functions and rebind inside","If you need this-like behavior in a helper, accept the table (or this) as an explicit parameter and use it consistently"],"exampleFix":"# before\njoined = t1.join(t2, t1.k == t2.k).select(t1.this.v)  # may raise: usage of this not supported\n\n# after\njoined = t1.join(t2, t1.k == t2.k).select(t1.v, t2.w)","handlingStrategy":"type-guard","validationCode":"def rebuild_ref(table, name: str):\n    \"\"\"Always bind references to a concrete table, never to a stale this.\"\"\"\n    return table[name]","typeGuard":"def ref_bound_to_concrete_table(ref) -> bool:\n    t = getattr(ref, \"table\", None)\n    return t is not None and not hasattr(t, \"_base_this\")","tryCatchPattern":"try:\n    result = helper_using_this()\nexcept TypeError as e:\n    if \"not supported here\" in str(e):\n        raise RuntimeError(\"rebuild the expression against a concrete table\") from e\n    raise","preventionTips":["Do not store this-references from join/ingest contexts in variables that outlive the context","Pass tables and column-name strings into helpers; bind references inside","Keep expressions referencing t1.x/t2.x inline within the join call"],"tags":["pathway","this","join","substitution","typeerror"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}