Skip to content

fix(parquet): skip empty CDC page flushes in add_data_page - #11003

Merged
Rich-T-kid merged 5 commits into
apache:mainfrom
M-Tesla:fix-10929-cdc-empty-page
Oct 28, 2026
Merged

Rich-T-kid merged 5 commits into
apache:mainfrom
M-Tesla:fix-10929-cdc-empty-page

Conversation

@M-Tesla

@M-Tesla M-Tesla commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Content-defined chunking forces a data page break after every chunk except the last. Writing the chunk can already have flushed that page, when the chunk hits data_page_size_limit or data_page_row_count_limit exactly at the boundary. The forced add_data_page then flushes with nothing buffered.

For BOOLEAN under PARQUET_2_0 (RLE), that panics: RLE value encoder is not initialized. Other encodings do not panic, but they write a data page with zero values.

should_add_data_page, dict_fallback, and flush_data_pages already skip the empty case. add_data_page did not.

What changes are included in this PR?

GenericColumnWriter::add_data_page returns Ok(()) when num_buffered_values == 0.

No public API change.

Are these changes tested?

  • BOOLEAN, 500k rows, data_page_size_limit(1024) and CDC 8KiB/16KiB: write succeeds, no empty data pages, roundtrip row count matches
  • INT32, 500k rows, data_page_row_count_limit(128) and the same CDC options: no empty data pages

cargo test -p parquet --lib -- cdc_boolean_small_pages_does_not_panic and cdc_int32_row_count_limit_does_not_emit_empty_pages. cargo clippy -p parquet --lib -- -D warnings.

Are there any user-facing changes?

BOOLEAN CDC writes that previously panicked now succeed. Empty data pages are no longer emitted for the same forced-break case on other encodings.

AI Disclosure

Assisted draft of the empty-buffer guard and regression tests. The skip matches the existing guards on should_add_data_page, dict_fallback, and flush_data_pages. Reviewed and verified with the checks above.

A forced content-defined chunk boundary can run after the chunk already
flushed its page. Flushing with nothing buffered panics BOOLEAN RLE and
emits zero-value pages for other encodings.
@github-actions github-actions Bot added the parquet parquet crate label Sep 5, 2026
ryux1

This comment was marked as spam.

@haohuaijin haohuaijin 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 @M-Tesla, LGTM, some suggestion for test case: could we use fewer rows here? 32,768 for BOOLEAN and 8,192 for INT32 reliably reproduce the issues. It might also be worth sharing the CDC setup between the two tests.

32768 BOOLEAN rows and 8192 INT32 rows are enough, and both tests share one CDC setup.
@M-Tesla

M-Tesla commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @haohuaijin. I shrank the BOOLEAN test to 32768 rows and the INT32 test to 8192, and both tests now share one CDC setup. The empty-page checks are unchanged.

@haohuaijin haohuaijin 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.

LGTM, two small suggestion.

Comment thread parquet/src/column/chunker/cdc.rs Resolved
Comment thread parquet/src/column/writer/mod.rs Resolved
@haohuaijin

Copy link
Copy Markdown
Contributor

cc @adriangb

@Rich-T-kid Rich-T-kid 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.

this looks good to me, left a few suggestions

Comment thread parquet/src/column/chunker/cdc.rs Resolved
Comment thread parquet/src/column/chunker/cdc.rs Resolved
Comment thread parquet/src/column/writer/mod.rs Resolved
@adriangb

Copy link
Copy Markdown
Contributor

Glad to see this being fixed!

@Rich-T-kid

Copy link
Copy Markdown
Contributor

@M-Tesla can you enable the CI to run on your fork?

The BOOLEAN test already says the row count is large enough to hit CDC chunk boundaries. The INT32 test has the same ignore and no note.
@M-Tesla

M-Tesla commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@Rich-T-kid actions are enabled on the fork. :)
I merged current main so this branch has ci.yml, and the fork CI run is queued.

The fork CI check looks for ci.yml on this branch. That workflow landed on main after the branch was cut.
@Rich-T-kid

Copy link
Copy Markdown
Contributor

can you resolve the remaining threads

The two tests share one helper, both Miri ignores say why, and the empty-page comment keeps the no-op line and the OffsetIndex note.
@M-Tesla

M-Tesla commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for leaving those notes. The helper, the Miri reasons, and the comment are in now.

@Rich-T-kid Rich-T-kid 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.

@Rich-T-kid
Rich-T-kid added this pull request to the merge queue Oct 28, 2026
Merged via the queue into apache:main with commit 81392e3 Oct 28, 2026
21 checks passed
@Jefffrey Jefffrey added the bug Squash those bugs label Nov 1, 2026
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.

Writing a BOOLEAN column with content-defined chunking panics with "RLE value encoder is not initialized"

6 participants