pathwaycom/pathway · error · ValueError
Duplicate expression value given for {name}
Error message
Duplicate expression value given for {name} What it means
Pathway's select/with_columns-style APIs merge positional column references and keyword arguments into a single name->expression mapping. This ValueError is raised when two inputs resolve to the same output column name, because a column cannot be defined twice in one operation. The name for positional args comes from expr.smart_name(), so a positional column and a kwarg (or two columns from different tables with the same name) can silently collide.
Source
Thrown at python/pathway/internals/desugaring.py:304
evaled_table = arg._eval_substitution(substitution)
new_kwargs.update(evaled_table)
return {
name: _desugar_this_arg(substitution, arg) for name, arg in new_kwargs.items()
}
def combine_args_kwargs(
args: Iterable[expr.ColumnReference],
kwargs: Mapping[str, Any],
exclude_columns: set[str] | None = None,
) -> dict[str, expr.ColumnExpression]:
all_args = {}
def add(name, expression):
if exclude_columns is not None and name in exclude_columns:
return
if name in all_args:
raise ValueError(f"Duplicate expression value given for {name}")
if name == "id":
raise ValueError("Can't use 'id' as a column name")
if not isinstance(expression, expr.ColumnExpression):
expression = expr.ColumnConstExpression(expression)
all_args[name] = expression
for expression in args:
add(expr.smart_name(expression), expression)
for name, expression in kwargs.items():
add(name, expression)
return all_args
class DesugaringContext:
_substitution: dict[thisclass.ThisMetaclass, table.Joinable] = {}
@propertyView on GitHub (pinned to fa2f74a464)
Solutions
- Remove the duplicate: keep either the positional reference or the kwarg, not both, e.g. use select(a=t.b) to rename instead of passing both t.a and a=...
- Rename colliding columns explicitly with kwarg syntax (select(left_value=t1.a, right_value=t2.a)) when selecting same-named columns from multiple tables
- If building kwargs dynamically from a dict, filter out names already supplied positionally (or pass exclude_columns where the API supports it) before calling select
Example fix
// before table.select(table.a, a=table.b) // after table.select(a=table.b)
Defensive patterns
Strategy: validation
Validate before calling
from pathway.internals import expression as expr
def safe_select_kwargs(args, kwargs):
names = [expr.smart_name(a) for a in args]
for name in kwargs:
if name in names:
raise ValueError(f"duplicate column name '{name}' in select arguments")
return kwargs Try / catch
try:
table.select(*args, **kwargs)
except ValueError as e:
if "Duplicate expression value given" in str(e):
# dedupe names and retry with explicit renames
... Prevention
- Never pass a column positionally and also as a kwarg with the same name
- When selecting from joined tables, rename same-named columns explicitly
- Build kwargs dynamically with a dict and check for collisions against positional names before the call
When it happens
Trigger: Calling table.select(t.a, a=t.b) or table.select(t1.a, t2.a) where smart_name of a positional reference equals a kwarg key or another positional's name; also select(*t1.columns, **{'a': t2.a}) patterns and with_columns variants that route through combine_args_kwargs.
Common situations: Renaming via kwargs while also passing the original column positionally; selecting same-named columns from two joined tables without renaming; copying a dict comprehension into kwargs that duplicates an existing column name; exclude_columns not covering the duplicate.
Related errors
- Join received extra kwargs. You probably want to use TableLi
- synchronization_group can only be set once
- Can't use 'id' as a column name
- Cannot use expression as boolean.
- unit has to be one of s, ms, us, ns but is {unit}.
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/54b9347e7001505c.
Report an issue: GitHub.