fix(parquet): do not cache an ALP preset built from an empty first page - #11004
Open
Abdallah-Afifi wants to merge 1 commit into
Open
fix(parquet): do not cache an ALP preset built from an empty first page#11004Abdallah-Afifi wants to merge 1 commit into
Abdallah-Afifi wants to merge 1 commit into
Conversation
When the first data page of a column chunk has no values, build_preset falls back to exponent 0 / factor 0. flush_buffer cached that preset for the whole chunk, so every fractional value in every later page became an exception. Only cache the preset once a page actually has values. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
AndreaBozzo
reviewed
Sep 6, 2026
AndreaBozzo
left a comment
Contributor
There was a problem hiding this comment.
The change looks clean to me, i'll wait for workflows to run and for someone else to eventually flag something more.
Author
I think the workflows need maintainer approval to start. Also, should I get on the rest of the subtasks related to ALP encoding? I would be happy to work on that. Thank you! |
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?
Rationale for this change
When a column chunk's first data page has no values,
build_presetreturns the fallback pair (exponent 0, factor 0).flush_buffercached that for the whole chunk, andselect_paramsshort-circuits on a single-candidate preset, so every later page was stuck on an integer scale and every fractional value became an exception.It's reachable from the normal write path, not just the encoder API: the column writer counts levels rather than values, so a first page of all nulls flushes an empty buffer.
Encoding 3000 values of
i * 0.01(raw f64 would be 24,000 bytes):Before the fix the chunk ends up bigger than leaving it unencoded. After, a leading empty page costs only its 7-byte header.
What changes are included in this PR?
flush_bufferonly caches the preset when the page had values.putalready branches on whether the preset is set, so the next page with values builds it.The issue asks only for regression coverage and @alamb suggested the fix as a follow-up — this has both. Happy to split them if you'd rather.
Are these changes tested?
test_empty_first_page_does_not_poison_preset, which fails on main. Fullcargo test -p parquetpasses (1558 tests); fmt and clippy clean.One thing I'd like a second opinion on: with the preset left unset, an all-null first page no longer arms the streaming path, so the second page takes the buffered path. The tests agree that's correct, but it's the part of this I'm least certain about.
Per the AI policy in CONTRIBUTING.md: I used Claude Code to trace the encoder and draft the fix and test. I've reviewed all of it and verified the behaviour myself — the numbers above are measured locally on this branch and on main.