{"record":{"id":"58f142b2fe135670","repo":"pola-rs/polars","slug":"left-join-column-name-r-not-found","errorCode":null,"errorMessage":"left join column {name!r} not found","messagePattern":"left join column (.+?) not found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/frame.py","lineNumber":9400,"sourceCode":"                    msg = \"missing join columns for left frame\"\n                    raise ValueError(msg)\n                if right_on is None:\n                    msg = \"missing join columns for right frame\"\n                    raise ValueError(msg)\n        else:\n            # move on into left/right_on to simplify logic\n            left_on = right_on = on\n\n        if isinstance(left_on, str):\n            left_on = [left_on]\n        if isinstance(right_on, str):\n            right_on = [right_on]\n\n        left_schema = self.collect_schema()\n        for name in left_on:\n            if name not in left_schema:\n                msg = f\"left join column {name!r} not found\"\n                raise ValueError(msg)\n        right_schema = other.collect_schema()\n        for name in right_on:\n            if name not in right_schema:\n                msg = f\"right join column {name!r} not found\"\n                raise ValueError(msg)\n\n        # no need to join if *only* join columns are in other (inner/left update only)\n        if how != \"full\" and len(right_schema) == len(right_on):\n            if row_index_name is not None:\n                return self.drop(row_index_name)\n            return self\n\n        # only use non-idx right columns present in left frame\n        right_other = set(right_schema).intersection(left_schema) - set(right_on)\n\n        # When include_nulls is True, we need to distinguish records after the join that\n        # were originally null in the right frame, as opposed to records that were null\n        # because the key was missing from the right frame.","sourceCodeStart":9382,"sourceCodeEnd":9418,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/lazyframe/frame.py#L9382-L9418","documentation":"Before joining, LazyFrame.update resolves self.collect_schema() and validates every name in left_on (or `on`) against it. An unknown left key name raises ValueError with the missing name interpolated.","triggerScenarios":"lf.update(other, on='Id') when the left frame's column is 'id'; typos; upstream rename/select removed the key; using the RIGHT frame's key name in `on`/left_on when names differ.","commonSituations":"Schema drift in pipelines (a select/rename earlier in the chain changed names); case-mismatched keys ('Id' vs 'id'); keys that differ between frames.","solutions":["Inspect the schema with lf.collect_schema() and use the exact left-frame name in `on`/left_on","If key names differ, use left_on/right_on with each frame's own name","If upstream renamed the key, rename it back or update downstream references"],"exampleFix":"// before\nlf.update(other, on='Id')  # left column is actually 'id'\n\n// after\nlf.update(other, left_on='id', right_on='Id')","handlingStrategy":"validation","validationCode":"left_keys = [on] if isinstance(on, str) else (on or left_on or [])\nleft_schema = lf.collect_schema()\nmissing = [c for c in left_keys if c not in left_schema]\nif missing:\n    raise KeyError(f'left keys not in schema: {missing}; have {list(left_schema)}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use lf.collect_schema() (not df.columns on a different frame) to verify lazy key names before update/join","Prefer consistent key naming upstream so `on` works everywhere"],"tags":["polars","update","join","schema","column-not-found"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}