fix: reject Parquet files with duplicate column names instead of silently dropping data - #24412
Closed
waterWang wants to merge 2 commits into
Closed
fix: reject Parquet files with duplicate column names instead of silently dropping data#24412waterWang wants to merge 2 commits into
waterWang wants to merge 2 commits into
Conversation
…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
Contributor
|
we already have a PR for this |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 callsSchema::try_merge, which silently deduplicates fields by name, dropping the second column without warning.This PR adds a validation step in
infer_schemathat 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:
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 tovalue_1; if users need that behavior, they can migrate the file externally.