{"record":{"id":"aa36a9fc0121c083","repo":"pola-rs/polars","slug":"cross-join-should-not-pass-join-keys","errorCode":null,"errorMessage":"cross join should not pass join keys","messagePattern":"cross join should not pass join keys","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/frame.py","lineNumber":6447,"sourceCode":"            raise ValueError(msg)\n\n        if how == \"outer\":\n            how = \"full\"\n            issue_deprecation_warning(\n                \"use of `how='outer'` should be replaced with `how='full'`.\",\n                version=\"0.20.29\",\n            )\n        elif how == \"outer_coalesce\":  # type: ignore[comparison-overlap]\n            coalesce = True\n            how = \"full\"\n            issue_deprecation_warning(\n                \"use of `how='outer_coalesce'` should be replaced with `how='full', coalesce=True`.\",\n                version=\"0.20.29\",\n            )\n        elif how == \"cross\":\n            if uses_on or uses_lr_on:\n                msg = \"cross join should not pass join keys\"\n                raise ValueError(msg)\n            return self._from_pyldf(\n                self._ldf.join(\n                    other._ldf,\n                    [],\n                    [],\n                    allow_parallel,\n                    force_parallel,\n                    nulls_equal,\n                    how,\n                    suffix,\n                    validate,\n                    maintain_order,\n                    build_side=build_side,\n                    coalesce=None,\n                )\n            )\n\n        if uses_on:","sourceCodeStart":6429,"sourceCodeEnd":6465,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/lazyframe/frame.py#L6429-L6465","documentation":"A cross join (how='cross') is the Cartesian product of both frames and takes no join keys. Passing on=, left_on=, or right_on= together with how='cross' raises ValueError immediately.","triggerScenarios":"lf.join(other, on='id', how='cross'); generic join wrappers that always forward join keys even when the caller selects cross; changing how= to 'cross' in existing code without removing keys.","commonSituations":"Switching an existing join to cross for combinatorics (e.g. grid generation); shared join helper functions with fixed key parameters.","solutions":["Remove all key arguments for cross joins: lf.join(other, how='cross')","In generic wrappers, conditionally omit keys when how == 'cross'","Consider pl.concat(..., how='diagonal') or product logic if a keyed cross-like result was intended"],"exampleFix":"# before\nlf.join(other, on='id', how='cross')\n\n# after\nlf.join(other, how='cross')","handlingStrategy":"validation","validationCode":"if how == 'cross':\n    lf = lf.join(other, how='cross')\nelse:\n    lf = lf.join(other, on=on, left_on=left_on, right_on=right_on, how=how)","typeGuard":"def is_keyless_join(how: str) -> bool:\n    return how == 'cross'","tryCatchPattern":null,"preventionTips":["Branch on how=='cross' in generic join helpers and strip keys","Remember cross join output rows = left_height * right_height; add limits"],"tags":["polars","lazyframe","join","cross-join"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}