{"record":{"id":"c7393af22e4d943e","repo":"pathwaycom/pathway","slug":"you-cannot-use-dep-to-column-expression-in-thi-c7393a","errorCode":null,"errorMessage":"You cannot use {dep.to_column_expression()} in this context. Its universe is different than the universe of the table the method was called on. You can use <table1>.with_universe_of(<table2>) to assign universe of <table2> to <table1> if you're sure their sets of keys are equal.","messagePattern":"You cannot use (.+?) in this context\\. Its universe is different than the universe of the table the method was called on\\. You can use <table1>\\.with_universe_of\\(<table2>\\) to assign universe of <table2> to <table1> if you're sure their sets of keys are equal\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/table.py","lineNumber":2509,"sourceCode":"    def _unsafe_promise_universe(self, other: TableLike) -> Table:\n        context = clmn.PromiseSameUniverseContext(self._id_column, other._id_column)\n        return self._table_with_context(context)\n\n    @contextualized_operator\n    def _unsafe_promise_universe_as_of_now(self, other: TableLike) -> Table:\n        \"\"\"Updates the universe of ``self`` to the universe of ``other``.\n        Stricter than _unsafe_promise_universe. Both universes have\n        to have updates to the same keys at the same processing time.\"\"\"\n\n        context = clmn.PromiseSameUniverseAsOfNowContext(\n            self._id_column, other._id_column\n        )\n        return self._table_with_context(context)\n\n    def _validate_expression(self, expression: expr.ColumnExpression):\n        for dep in expression._dependencies_above_reducer():\n            if self._universe != dep._column.universe:\n                raise ValueError(\n                    f\"You cannot use {dep.to_column_expression()} in this context.\"\n                    + \" Its universe is different than the universe of the table the method\"\n                    + \" was called on. You can use <table1>.with_universe_of(<table2>)\"\n                    + \" to assign universe of <table2> to <table1> if you're sure their\"\n                    + \" sets of keys are equal.\"\n                )\n\n    def _check_for_disallowed_types(self, *expressions: expr.ColumnExpression):\n        for expression in expressions:\n            dtype = self.eval_type(expression)\n            if isinstance(dtype, dt.Future):\n                raise TypeError(\n                    f\"Using column of type {dtype.typehint} is not allowed here.\"\n                    + \" Consider applying `await_futures()` to the table first.\"\n                )\n\n    def _wrap_column_in_context(\n        self,","sourceCodeStart":2491,"sourceCodeEnd":2527,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/table.py#L2491-L2527","documentation":"Raised by Table._validate_expression when an expression passed to a table method depends (above any reducer) on a column whose universe differs from the table the method was called on. Pathway expressions are universe-scoped: a column from another table's row set cannot be evaluated row-wise on this table. The message suggests with_universe_of as the explicit escape hatch.","triggerScenarios":"t1.with_columns(x=t2.col + 1) where t2 has a different universe than t1; using a column captured from another table inside filter/select/with_columns; using a non-reduced column from a different table after a groupby/join without proper context.","commonSituations":"Mixing columns of two tables in one expression instead of joining first; refactors that moved a column computation to a different table; forgetting that join result columns carry the joined universe.","solutions":["Join the tables first, then use the joined columns: tj = t1.join(t2, t1.k == t2.k).select(t1.a, t2.b)","If the universes are provably equal, assert it: t2 = t2.with_universe_of(t1) — but only when key sets truly match","For aggregates from another table, reduce them (e.g. t2.reduce(cnt=pw.reducers.count())) so the dependency crosses universes via a reducer","Check universes in tests with pw.debug.compute_and_print before asserting equality"],"exampleFix":"# before\nt3 = t1.with_columns(x=t2.value + 1)  # different universes -> ValueError\n\n# after\nt3 = t1.join(t2, t1.key == t2.key).select(*pw.left, x=pw.right.value + 1)","handlingStrategy":"validation","validationCode":"def same_universe(t1, t2) -> bool:\n    return t1._universe == t2._universe\n\n# only use with_universe_of when this returns True in practice","typeGuard":null,"tryCatchPattern":"try:\n    t3 = t1.with_columns(x=expr_from_t2)\nexcept ValueError as e:\n    if 'different than the universe' in str(e):\n        tj = t1.join(t2, t1.k == t2.k)\n        t3 = tj.select(*pw.left, x=pw.right.col + 1)","preventionTips":["Join before combining columns from two tables","Never assume universes are equal without asserting via with_universe_of","Reduce foreign aggregates with reducers instead of raw cross-universe columns"],"tags":["pathway","universe","expressions","join"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}