pola-rs/polars · error · InvalidOperationError

strategy requires at least one common column

Error message

{how!r} strategy requires at least one common column

What it means

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.

Solutions

  1. Rename columns so frames share at least one key column
  2. Verify shared columns with `set(df1.columns) & set(df2.columns)` before concatenating
  3. If no alignment is intended, use `how='horizontal'` or `'diagonal'` instead

Example fix

// before
pl.concat([df1, df2.rename({'user_id': 'id'})], how='align')
// after
assert set(df1.columns) & set(df2.columns), 'no common columns'
pl.concat([df1, df2], how='align')
Defensive patterns

Strategy: validation

Validate before calling

cols = set(dfs[0].columns)
for df in dfs[1:]:
    cols &= set(df.columns)
if not cols:
    raise ValueError('frames share no common columns for align concat')
result = pl.concat(dfs, how='align')

Try / catch

try:
    result = pl.concat(dfs, how='align')
except pl.exceptions.InvalidOperationError as e:
    if 'common column' in str(e):
        result = pl.concat(dfs, how='diagonal')
    else:
        raise

Prevention

When it happens

Trigger: Calling `pl.concat([df1, df2], how='align')` where `df1.columns` and `df2.columns` have zero intersection.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/72667709b6f7d0f1. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/functions/eager.py:249

        ):
            msg = f"{how!r} strategy is not supported for {qualified_type_name(elems[0])!r}"
            raise TypeError(msg)

        # establish common columns, maintaining the order in which they appear
        all_columns = list(chain.from_iterable(e.collect_schema() for e in elems))
        key = {v: k for k, v in enumerate(ordered_unique(all_columns))}
        output_column_order = list(key)
        common_cols = sorted(
            reduce(
                lambda x, y: set(x) & set(y),  # type: ignore[arg-type, return-value]
                chain(e.collect_schema() for e in elems),
            ),
            key=lambda k: key.get(k, 0),
        )
        # we require at least one key column for 'align' strategies
        if not common_cols:
            msg = f"{how!r} strategy requires at least one common column"
            raise InvalidOperationError(msg)

        # align frame data using a join, with no suffix-resolution (will raise
        # a DuplicateError in case of column collision, same as "horizontal")
        join_method: JoinStrategy = (
            "full" if how == "align" else how.removeprefix("align_")  # type: ignore[assignment]
        )
        join_frames = [df.lazy() for df in elems]

        def join_fn(x: pl.LazyFrame, y: pl.LazyFrame) -> pl.LazyFrame:
            return x.join(
                y,
                on=common_cols,
                how=join_method,
                maintain_order="right_left",
                coalesce=True,
            )

        if join_method in ("full", "inner"):

View on GitHub (pinned to fe841f959e)