pathwaycom/pathway · error · ValueError
Can't use 'id' as a column name
Error message
Can't use 'id' as a column name
What it means
Pathway reserves the column name 'id' for the table's primary key (the auto-generated pointer column), so user data columns cannot be named 'id'. combine_args_kwargs raises this ValueError as soon as any positional smart_name or kwarg key equals 'id', before the expression is ever evaluated.
Source
Thrown at python/pathway/internals/desugaring.py:306
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] = {}
@property
@abstractmethod
def _desugaring(self) -> DesugaringTransform:View on GitHub (pinned to fa2f74a464)
Solutions
- Rename the column to anything else, e.g. select(row_id=table.id) or use a schema with field name like object_id
- In a schema definition, declare the key with a different name (e.g. class Schema(pw.Schema, id_column='object_id')) so the key column is not called 'id'
- When reading a data source with an 'id' column, map it in the connector/schema to a different output name before selecting
Example fix
// before
table.select(id=pw.this.left)
// after
class Out(pw.Schema, id_column='object_id'):
object_id: int
left: int
table.select(object_id=pw.this.left) Defensive patterns
Strategy: validation
Validate before calling
RESERVED = {"id"}
def validate_column_names(kwargs: dict):
bad = RESERVED & set(kwargs)
if bad:
raise ValueError(f"reserved column names not allowed: {bad}") Prevention
- Never name output columns 'id'; Pathway reserves it for the primary key
- Use id_column=... in your schema class to control the key's name explicitly
- Rename incoming 'id' data columns at the connector/schema level before select
When it happens
Trigger: table.select(id=table.key) or table.select(table.id_col) where the referenced column is literally named 'id'; with_columns(id=...); passing a schema class or kwargs containing an 'id' field through the same desugaring path.
Common situations: Porting pandas/SQL code where 'id' is a natural column name; reading external data whose columns include 'id' and then doing select(*cols) or rename operations; joining and trying to re-expose the key as 'id'.
Related errors
- Incorrect S3 path: {s3_path}
- SchemaRegistryHeader.key must be a str, got {type(self.key).
- Duplicate expression value given for {name}
- Iceberg reader requires explicit primary key fields specific
- primary_key column {primary_key._name!r} does not belong to
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/555e26ef54c5f970.
Report an issue: GitHub.