{"record":{"id":"555e26ef54c5f970","repo":"pathwaycom/pathway","slug":"can-t-use-id-as-a-column-name","errorCode":null,"errorMessage":"Can't use 'id' as a column name","messagePattern":"Can't use 'id' as a column name","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/desugaring.py","lineNumber":306,"sourceCode":"    return {\n        name: _desugar_this_arg(substitution, arg) for name, arg in new_kwargs.items()\n    }\n\n\ndef combine_args_kwargs(\n    args: Iterable[expr.ColumnReference],\n    kwargs: Mapping[str, Any],\n    exclude_columns: set[str] | None = None,\n) -> dict[str, expr.ColumnExpression]:\n    all_args = {}\n\n    def add(name, expression):\n        if exclude_columns is not None and name in exclude_columns:\n            return\n        if name in all_args:\n            raise ValueError(f\"Duplicate expression value given for {name}\")\n        if name == \"id\":\n            raise ValueError(\"Can't use 'id' as a column name\")\n        if not isinstance(expression, expr.ColumnExpression):\n            expression = expr.ColumnConstExpression(expression)\n        all_args[name] = expression\n\n    for expression in args:\n        add(expr.smart_name(expression), expression)\n    for name, expression in kwargs.items():\n        add(name, expression)\n\n    return all_args\n\n\nclass DesugaringContext:\n    _substitution: dict[thisclass.ThisMetaclass, table.Joinable] = {}\n\n    @property\n    @abstractmethod\n    def _desugaring(self) -> DesugaringTransform:","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/desugaring.py#L288-L324","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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"],"exampleFix":"// before\ntable.select(id=pw.this.left)\n// after\nclass Out(pw.Schema, id_column='object_id'):\n    object_id: int\n    left: int\ntable.select(object_id=pw.this.left)","handlingStrategy":"validation","validationCode":"RESERVED = {\"id\"}\n\ndef validate_column_names(kwargs: dict):\n    bad = RESERVED & set(kwargs)\n    if bad:\n        raise ValueError(f\"reserved column names not allowed: {bad}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["pathway","reserved-name","primary-key","column-selection"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}