{"record":{"id":"eb3a2139067a3a11","repo":"pathwaycom/pathway","slug":"table-expected-here","errorCode":null,"errorMessage":"Table expected here.","messagePattern":"Table expected here\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/table.py","lineNumber":1468,"sourceCode":"        ... 4 | owl\n        ... ''')\n        >>> ret = t_birds.select(t_birds.desc, latin=t_animals.ix(t_birds.id).genus)\n        >>> pw.debug.compute_and_print(ret, include_id=False)\n        desc   | latin\n        hoopoe | atropos\n        owl    | hercules\n        \"\"\"\n\n        if context is None:\n            all_tables = collect_tables(expression)\n            if len(all_tables) == 0:\n                context = thisclass.this\n            elif all(tab == all_tables[0] for tab in all_tables):\n                context = all_tables[0]\n        if context is None:\n            for tab in all_tables:\n                if not isinstance(tab, Table):\n                    raise ValueError(\"Table expected here.\")\n            if len(all_tables) == 0:\n                raise ValueError(\"Const value provided.\")\n            context = all_tables[0]\n            for tab in all_tables:\n                assert context._universe.is_equal_to(tab._universe)\n        if isinstance(context, groupbys.GroupedJoinable):\n            context = thisclass.this\n        if isinstance(context, thisclass.ThisMetaclass):\n            return context._delayed_op(\n                lambda table, expression: self.ix(\n                    expression=expression,\n                    optional=optional,\n                    context=table,\n                    allow_misses=allow_misses,\n                ),\n                expression=expression,\n                qualname=f\"{self}.ix(...)\",\n                name=\"ix\",","sourceCodeStart":1450,"sourceCodeEnd":1486,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/table.py#L1450-L1486","documentation":"Table.ix() needs a context table to know which rows to evaluate the index expression against. It collects all tables referenced in the expression; if they are not all the same table, context stays None, and the fallback loop then requires every collected item to be an actual Table instance. ValueError('Table expected here.') means the expression mixes a non-Table joinable (e.g. a GroupedTable or grouped context leaked into the expression) with regular tables, so no single evaluation context can be chosen.","triggerScenarios":"Calling t.ix(expr) where expr references columns from several different tables, or uses a GroupedTable / pw.this from a grouped context alongside other tables; heterogeneous expressions inside reduce/ix callbacks.","commonSituations":"Building an ix lookup expression in a grouped reduce that also references an outer table; copy-pasted snippet mixing t1.col and t2.col in one expression passed to ix.","solutions":["Make the ix expression reference exactly one table (or only pw.this) — join the needed tables beforehand","Inside grouped reductions, reference only the grouped table's columns and perform cross-table lookups via a separate join","Simplify: compute intermediate columns with with_columns before ix so the expression is a single column reference"],"exampleFix":"# before\nval = prices.ix(rates.currency * prices.qty)  # mixes two tables -> ValueError\n\n# after\njoined = prices.join(rates, prices.currency == rates.currency)\nval = joined.ix(joined.rate * joined.qty)","handlingStrategy":"validation","validationCode":"import pathway as pw\nfrom pathway.internals.expressions import dereference\n\ndef ix_expression_is_single_table(expr, context_table) -> bool:\n    tables = pw.Table._collect_tables(expr) if hasattr(pw.Table, '_collect_tables') else []\n    return all(t is context_table for t in tables) if tables else False","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep ix expressions referencing one table only; join beforehand","Avoid mixing outer table references into expressions used inside grouped reductions"],"tags":["ix","context","pathway"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}