Skip to content

GH-51684: [C++][Parquet] Keep the CDC chunking state across row groups - #51685

Open
kszucs wants to merge 2 commits into
apache:mainfrom
kszucs:cdc-row-group-reset
Open

kszucs wants to merge 2 commits into
apache:mainfrom
kszucs:cdc-row-group-reset

Conversation

@kszucs

@kszucs kszucs commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

The content-defined chunker was owned by the column writer, which is recreated for every row group, so the chunking state was reset at each row group boundary and page boundaries depended on where a row group starts. See #51684.

What changes are included in this PR?

  • The file writer creates one chunker per leaf column when it opens and passes it to the column writers of every row group through a private ColumnWriter::Make() overload.
  • The file writer computes each column's level information once and shares it with the chunker and the column writers.
  • A column writer requires a chunker when content-defined chunking is enabled, so the public ColumnWriter::Make() now rejects such properties.
  • NextColumn() advances the column ordinal together with the column metadata, before closing the previous column writer. Previously, if that close threw and the caller called NextColumn() again, the ordinal fell one column behind the metadata, and the new column writer would have used the previous column's chunker.

Are these changes tested?

Yes. IndependentOfRowGroupBoundaries writes the same table into one and into multiple row groups and expects the same page boundaries apart from the row group ends; the first commit adds it alone, failing without the fix.

Are there any user-facing changes?

Files with multiple row groups get different page boundaries than before, since the chunking now continues across row groups. ColumnWriter::Make() throws if the writer properties enable content-defined chunking; such column writers have to come from the file writer. Multi-threaded writes with content-defined chunking are about 1.7× slower until the follow-up #51692 keeps the chunker's state in registers (9.9 ms vs 5.8 ms writing 12 int32 columns of 1M rows on an Apple M4 Max, 4.4 ms with the follow-up): the chunkers are now created together, so the threads writing neighbouring columns contend for their cache lines.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

Claude Code wrote the code, tests and description under human direction.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

🤖 Generated with Claude Code

The column writer owns the content defined chunker and is recreated for every
row group, so the chunking state is reset at each row group boundary. Writing
the same table into one and into multiple row groups must give the same page
boundaries apart from the row group ends.
@kszucs
kszucs force-pushed the cdc-row-group-reset branch 4 times, most recently from ed7b88a to 10d98d8 Compare October 2, 2026 10:14
@kszucs
kszucs marked this pull request as ready for review October 2, 2026 10:31
Copilot AI balanced review requested due to automatic review settings October 2, 2026 10:31

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The changed public factory breaks ABI and disables CDC for existing direct callers.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Persists Parquet content-defined chunking state across row groups.

Changes:

  • Moves chunker ownership to the file writer.
  • Passes chunkers into successive column writers.
  • Adds row-group boundary independence coverage.
File Description
cpp/​src/​parquet/​file_writer.cc Manages per-column chunkers.
cpp/​src/​parquet/​column_writer.h Extends the column-writer factory.
cpp/​src/​parquet/​column_writer.cc Uses externally managed chunkers.
cpp/​src/​parquet/​chunker_internal.h Updates ownership documentation.
cpp/​src/​parquet/​chunker_internal.cc Stores level metadata by value.
cpp/​src/​parquet/​chunker_internal_test.cc Tests stable page boundaries.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cpp/src/parquet/column_writer.h Outdated
@kszucs
kszucs force-pushed the cdc-row-group-reset branch from 10d98d8 to 8d016a7 Compare October 2, 2026 13:54
Copilot AI balanced review requested due to automatic review settings October 2, 2026 13:54

This comment was marked as duplicate.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 15:29
@kszucs
kszucs force-pushed the cdc-row-group-reset branch from 8d016a7 to f556bae Compare October 2, 2026 15:29

This comment was marked as duplicate.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:35
@kszucs
kszucs force-pushed the cdc-row-group-reset branch from f556bae to 0a0f214 Compare October 2, 2026 16:35

This comment was marked as duplicate.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:38
@kszucs
kszucs force-pushed the cdc-row-group-reset branch from 0a0f214 to 0e77f38 Compare October 2, 2026 16:38

This comment was marked as duplicate.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:44
@kszucs
kszucs force-pushed the cdc-row-group-reset branch from 0e77f38 to f7a6240 Compare October 2, 2026 16:44

This comment was marked as duplicate.

The column writer created the chunker for every column chunk, so the chunking
state was reset at each row group. The file writer now keeps one chunker per
leaf column and passes it to the column writers of all the row groups.
Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:50
@kszucs
kszucs force-pushed the cdc-row-group-reset branch from f7a6240 to d5b7b42 Compare October 2, 2026 16:50

This comment was marked as duplicate.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants