Skip to content

fix(parquet): validate Arrow writer shapes and map-key schemas - #11838

Merged
etseidl merged 1 commit into
apache:mainfrom
HippoBaro:shape_validation
Oct 28, 2026
Merged

etseidl merged 1 commit into
apache:mainfrom
HippoBaro:shape_validation

Conversation

@HippoBaro

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

See #11837. Structural mismatches between the input batch, declared schemas, and column writers should produce descriptive errors rather than silently ignore columns or panic. Map-key schema constraints should also be enforced when an explicit Parquet schema bypasses Arrow-to-Parquet conversion.

What changes are included in this PR?

Reject mismatches between batch columns, planned Parquet leaves, physical column writers, and CDC chunkers instead of silently truncating zipped iteration or panicking on missing writers.

Derive per-field leaf ranges from the target Arrow schema and verify the Arrow/Parquet leaf counts when creating column writers. Check batch, writer, and chunker counts before updating row-group accounting, and validate each field's actual leaf count before dispatching its writes. Preserve compatible dense, dictionary, and run-end encoded representations.

Validate map-key schemas when creating an Arrow writer, including when an explicitly supplied Parquet schema bypasses Arrow-to-Parquet conversion.

Are these changes tested?

Add regression coverage for shape mismatches, invalid map-key schemas, and reachable versus masked or unreferenced map-key nulls. All tests passing.

Are there any significant user-facing changes?

No public API changes. Invalid schema or column-count combinations that were previously accepted, silently ignored, or caused a panic now return descriptive errors.

@github-actions github-actions Bot added parquet parquet crate bug Squash those bugs labels Oct 22, 2026
@HippoBaro

Copy link
Copy Markdown
Contributor Author

@etseidl This one is short and sweet (and mainly tests); let me know what you think 🙇

@Rich-T-kid

Copy link
Copy Markdown
Contributor

merging up to fix ci issues

@etseidl
etseidl self-requested a review October 27, 2026 04:35
@etseidl

etseidl commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Sorry @HippoBaro, this fell off my plate. I've added it to my queue for tomorrow.

@etseidl

etseidl commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Reject mismatches between batch columns, planned Parquet leaves,
physical column writers, and CDC chunkers instead of silently
truncating zipped iteration or panicking on missing writers.

Derive per-field leaf ranges from the target Arrow schema and verify
the Arrow/Parquet leaf counts when creating column writers. Check
batch, writer, and chunker counts before updating row-group accounting,
and validate each field's actual leaf count before dispatching its
writes. Preserve compatible dense, dictionary, and run-end encoded
representations.

Validate map-key schemas when creating an Arrow writer, including when
an explicitly supplied Parquet schema bypasses Arrow-to-Parquet
conversion.

Add regression coverage for shape mismatches, invalid map-key schemas,
and reachable versus masked or unreferenced map-key nulls.

Signed-off-by: Hippolyte Barraud <[email protected]>
@HippoBaro

HippoBaro commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @etseidl! I've rebased, and CI should now be running on my fork. Let me know if there's anything else I need to do 🙇

@etseidl etseidl left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @HippoBaro. It took awhile, but this looks correct to me. Looks like there's a CI issue to fix.

@HippoBaro

HippoBaro commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @etseidl! The CI failure seems to be failing to find a Darwin host to run tests on https://github.com/HippoBaro/arrow-rs/actions/runs/40522283146/job/122252954680

I have no idea how our CI setup is meant to work, but I doubt GitHub is giving free CI runs on macs do they?

EDIT: They do. There is the actual error:

Due to capacity constraints, jobs targeting macOS arm64 runners may experience longer queue times.

After a while the job failed instead of being queued indefinitely. I'll retry the failed job and we'll see if GH has enough cycles to spare this time 🤞

EDIT 2: It now passes https://github.com/HippoBaro/arrow-rs/actions/runs/40522283146

@etseidl
etseidl added this pull request to the merge queue Oct 28, 2026
Merged via the queue into apache:main with commit 7dcc160 Oct 28, 2026
21 checks passed
@HippoBaro

Copy link
Copy Markdown
Contributor Author

Thank you @etseidl and @Rich-T-kid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Squash those bugs parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parquet Arrow writer does not consistently validate schemas and column counts

3 participants