{"record":{"id":"eceb02f4c8772275","repo":"pathwaycom/pathway","slug":"const-value-provided","errorCode":null,"errorMessage":"Const value provided.","messagePattern":"Const value provided\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/table.py","lineNumber":1470,"sourceCode":"        >>> 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\",\n            )\n        restrict_universe = RestrictUniverseDesugaring(context)","sourceCodeStart":1452,"sourceCodeEnd":1488,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/table.py#L1452-L1488","documentation":"Companion guard in ix()'s context resolution: after collecting referenced tables, if the expression references no table at all (all_tables is empty), the constant/this fast paths have already failed to apply and ValueError('Const value provided.') is raised. Ix is a row-wise lookup — indexing with a constant that does not depend on any table row has no meaningful context, so Pathway rejects it.","triggerScenarios":"t.ix(42), t.ix('abc'), or t.ix(some_python_constant) — an expression containing no column references at all; passing a precomputed value instead of a column expression.","commonSituations":"Wrapping a computed scalar in ix expecting a broadcast; a variable that was supposed to hold a column reference but holds a plain value after refactoring.","solutions":["Index with a column expression of the table: t.ix(t.key_col)","If you need a constant column, add it via with_columns(const=pw.const(value)) instead of ix","Verify the argument is a ColumnReference/expression, not a literal, before calling ix"],"exampleFix":"# before\nv = t.ix(5)  # constant expression -> ValueError\n\n# after\nv = t.ix(t.index_col)      # row-dependent key\n# constant column instead:\nt = t.with_columns(const=pw.const(5))","handlingStrategy":"validation","validationCode":"from pathway.internals import expression as expr\n\ndef ix_arg_references_a_column(arg) -> bool:\n    return isinstance(arg, expr.ColumnReference) or (\n        isinstance(arg, expr.ColumnExpression) and arg._column_references()\n    )","typeGuard":"from pathway.internals import expression as expr\n\ndef is_column_expression(arg) -> bool:\n    return isinstance(arg, (expr.ColumnReference, expr.ColumnExpression))","tryCatchPattern":null,"preventionTips":["Pass column expressions to ix, never constants","Use pw.const/with_columns for constant columns"],"tags":["ix","api-misuse","pathway"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}