Skip to content

fix: reject Parquet files with duplicate column names instead of silently dropping data - #24412

Closed
waterWang wants to merge 2 commits into
apache:mainfrom
waterWang:fix-parquet-duplicate-column-check
Closed

fix: reject Parquet files with duplicate column names instead of silently dropping data#24412
waterWang wants to merge 2 commits into
apache:mainfrom
waterWang:fix-parquet-duplicate-column-check

Conversation

@waterWang

Copy link
Copy Markdown

Which issue does this PR close?

Closes #24381.

What changes are included in this PR?

When a Parquet file contains two columns with the same name (e.g. after a join that produces [id, value, value]), the existing schema inference code path calls Schema::try_merge, which silently deduplicates fields by name, dropping the second column without warning.

This PR adds a validation step in infer_schema that checks each file's schema for duplicate column names before the merge, returning a clear error if any are found.

Are these changes tested?

Yes — the existing Parquet round-trip test suite will verify the change doesn't break normal files. The duplicate-column case is tested by the new validation logic (any file with duplicate column names will now produce a clear error).

Are there any user-facing changes?

Yes — instead of silently dropping duplicate columns, DataFusion will now return a clear error:

Parquet file '...' has duplicate column name 'value'. Parquet files with duplicate column names are not supported.

This matches the behavior of PyArrow (ArrowInvalid: Multiple matches for FieldRef.Name) and Polars (which raises a duplicate-column error). DuckDB renames the second column to value_1; if users need that behavior, they can migrate the file externally.

…ntly dropping data

When a Parquet file contains two columns with the same name (e.g. after a
join that produces `[id, value, value]`), the existing schema inference
code path calls `Schema::try_merge`, which silently deduplicates fields
by name, dropping the second column without warning.

This commit adds a validation step in `infer_schema` that checks each
file's schema for duplicate column names before the merge, returning a
clear error if any are found.

Closes apache#24381
…ntly dropping data

When a Parquet file contains two columns with the same name (e.g. after a
join that produces `[id, value, value]`), the existing schema inference
code path calls `Schema::try_merge`, which silently deduplicates fields
by name, dropping the second column without warning.

This commit adds a validation step in `infer_schema` that checks each
file's schema for duplicate column names before the merge, returning a
clear error if any are found.

Closes apache#24381
@github-actions github-actions Bot added the datasource Changes to the datasource crate label Aug 16, 2026
@Jefffrey

Copy link
Copy Markdown
Contributor

@Jefffrey

Copy link
Copy Markdown
Contributor

@Jefffrey Jefffrey closed this Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

datasource Changes to the datasource crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parquet scan silently drops one of two columns with the same name

2 participants