{"record":{"id":"72667709b6f7d0f1","repo":"pola-rs/polars","slug":"how-r-strategy-requires-at-least-one-common-colu","errorCode":null,"errorMessage":"{how!r} strategy requires at least one common column","messagePattern":"(.+?) strategy requires at least one common column","errorType":"validation","errorClass":"InvalidOperationError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/functions/eager.py","lineNumber":249,"sourceCode":"        ):\n            msg = f\"{how!r} strategy is not supported for {qualified_type_name(elems[0])!r}\"\n            raise TypeError(msg)\n\n        # establish common columns, maintaining the order in which they appear\n        all_columns = list(chain.from_iterable(e.collect_schema() for e in elems))\n        key = {v: k for k, v in enumerate(ordered_unique(all_columns))}\n        output_column_order = list(key)\n        common_cols = sorted(\n            reduce(\n                lambda x, y: set(x) & set(y),  # type: ignore[arg-type, return-value]\n                chain(e.collect_schema() for e in elems),\n            ),\n            key=lambda k: key.get(k, 0),\n        )\n        # we require at least one key column for 'align' strategies\n        if not common_cols:\n            msg = f\"{how!r} strategy requires at least one common column\"\n            raise InvalidOperationError(msg)\n\n        # align frame data using a join, with no suffix-resolution (will raise\n        # a DuplicateError in case of column collision, same as \"horizontal\")\n        join_method: JoinStrategy = (\n            \"full\" if how == \"align\" else how.removeprefix(\"align_\")  # type: ignore[assignment]\n        )\n        join_frames = [df.lazy() for df in elems]\n\n        def join_fn(x: pl.LazyFrame, y: pl.LazyFrame) -> pl.LazyFrame:\n            return x.join(\n                y,\n                on=common_cols,\n                how=join_method,\n                maintain_order=\"right_left\",\n                coalesce=True,\n            )\n\n        if join_method in (\"full\", \"inner\"):","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/functions/eager.py#L231-L267","documentation":"Align-based concat strategies (`align`, `align_full`, `align_inner`, etc.) work by joining frames on their shared columns, so at least one common column must exist. `concat` raises InvalidOperationError when the frames share no columns, since there is no key to align on.","triggerScenarios":"Calling `pl.concat([df1, df2], how='align')` where `df1.columns` and `df2.columns` have zero intersection.","commonSituations":"Frames loaded from different sources with differently named key columns (e.g. 'id' vs 'user_id'); schema drift after an upstream rename; typos in column names.","solutions":["Rename columns so frames share at least one key column","Verify shared columns with `set(df1.columns) & set(df2.columns)` before concatenating","If no alignment is intended, use `how='horizontal'` or `'diagonal'` instead"],"exampleFix":"// before\npl.concat([df1, df2.rename({'user_id': 'id'})], how='align')\n// after\nassert set(df1.columns) & set(df2.columns), 'no common columns'\npl.concat([df1, df2], how='align')","handlingStrategy":"validation","validationCode":"cols = set(dfs[0].columns)\nfor df in dfs[1:]:\n    cols &= set(df.columns)\nif not cols:\n    raise ValueError('frames share no common columns for align concat')\nresult = pl.concat(dfs, how='align')","typeGuard":null,"tryCatchPattern":"try:\n    result = pl.concat(dfs, how='align')\nexcept pl.exceptions.InvalidOperationError as e:\n    if 'common column' in str(e):\n        result = pl.concat(dfs, how='diagonal')\n    else:\n        raise","preventionTips":["Compute set intersections of column names before align concat","Standardize key column names across sources","Prefer 'diagonal' when no common key is expected"],"tags":["polars","concat","align","no-common-columns"],"backgroundTag":"schema-validation-failed","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}