pathwaycom/pathway · error · ValueError

Const value provided.

Error message

Const value provided.

What it means

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.

Source

Thrown at python/pathway/internals/table.py:1470

        >>> ret = t_birds.select(t_birds.desc, latin=t_animals.ix(t_birds.id).genus)
        >>> pw.debug.compute_and_print(ret, include_id=False)
        desc   | latin
        hoopoe | atropos
        owl    | hercules
        """

        if context is None:
            all_tables = collect_tables(expression)
            if len(all_tables) == 0:
                context = thisclass.this
            elif all(tab == all_tables[0] for tab in all_tables):
                context = all_tables[0]
        if context is None:
            for tab in all_tables:
                if not isinstance(tab, Table):
                    raise ValueError("Table expected here.")
            if len(all_tables) == 0:
                raise ValueError("Const value provided.")
            context = all_tables[0]
            for tab in all_tables:
                assert context._universe.is_equal_to(tab._universe)
        if isinstance(context, groupbys.GroupedJoinable):
            context = thisclass.this
        if isinstance(context, thisclass.ThisMetaclass):
            return context._delayed_op(
                lambda table, expression: self.ix(
                    expression=expression,
                    optional=optional,
                    context=table,
                    allow_misses=allow_misses,
                ),
                expression=expression,
                qualname=f"{self}.ix(...)",
                name="ix",
            )
        restrict_universe = RestrictUniverseDesugaring(context)

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Index with a column expression of the table: t.ix(t.key_col)
  2. If you need a constant column, add it via with_columns(const=pw.const(value)) instead of ix
  3. Verify the argument is a ColumnReference/expression, not a literal, before calling ix

Example fix

# before
v = t.ix(5)  # constant expression -> ValueError

# after
v = t.ix(t.index_col)      # row-dependent key
# constant column instead:
t = t.with_columns(const=pw.const(5))
Defensive patterns

Strategy: validation

Validate before calling

from pathway.internals import expression as expr

def ix_arg_references_a_column(arg) -> bool:
    return isinstance(arg, expr.ColumnReference) or (
        isinstance(arg, expr.ColumnExpression) and arg._column_references()
    )

Type guard

from pathway.internals import expression as expr

def is_column_expression(arg) -> bool:
    return isinstance(arg, (expr.ColumnReference, expr.ColumnExpression))

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/eceb02f4c8772275. Report an issue: GitHub.