Skip to content

Parquet: Add opt-in uncompressed row group size tracking#16327

Merged
huaxingao merged 11 commits into
apache:mainfrom
nssalian:fix-parquet-row-group-size
Jun 7, 2026
Merged

Parquet: Add opt-in uncompressed row group size tracking#16327
huaxingao merged 11 commits into
apache:mainfrom
nssalian:fix-parquet-row-group-size

Conversation

@nssalian

@nssalian nssalian commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Closes: #16325

Rationale for this Change

Adds write.parquet.row-group-size-check-uncompressed (default false) to accurately enforce write.parquet.row-group-size-bytes when using compressing codecs (GZIP, ZSTD, etc.).

ParquetWriter.checkSize() uses writeStore.getBufferedSize() which reports compressed bytes for flushed pages. With effective compression, the writer never sees the target exceeded because it's comparing compressed data against an uncompressed limit. Row groups grow unbounded.

What changes are included in this PR?

When write.parquet.row-group-size-check-uncompressed=true:

  1. Measures getBufferedSize() before and after model.write() per record. Between these points, data is in uncompressed column buffers (no page flush occurs during model.write()). The delta is the exact uncompressed record size.
  2. Accumulates into rowGroupUncompressedSize. Flushes when it hits the target.
  3. Removes the 100-record minimum check interval floor for the uncompressed path.

Disabled by default.

When enabled getBufferedSize() calls per record. Each call iterates column writers adding field reads. It's the same pattern parquet-mr uses in ColumnWriteStoreBase.sizeCheck(). Kept it optional so as to not cause an immediate change to the default behavior.

Are these changes tested?

  • Parameterized test across all codecs (gzip, snappy, zstd, uncompressed)
  • Existing parquet tests pass locally

Are there any user-facing changes?

Yes. New configuration but set to false by default.

@nssalian

nssalian commented May 15, 2026

Copy link
Copy Markdown
Collaborator Author

CC: @pvary @steveloughran @huaxingao @aihuaxu PTAL

Comment thread parquet/src/main/java/org/apache/iceberg/parquet/ParquetWriter.java Outdated
@nssalian nssalian requested a review from steveloughran May 15, 2026 18:42

@steveloughran steveloughran 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, good test coverage.

@nssalian

Copy link
Copy Markdown
Collaborator Author

@Fokko PTAL when you get a chance

Comment thread docs/docs/configuration.md Outdated

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

production code looks valid, though I'd have factored out the common code myself.

regarding the tests, is it possible to show this working for smaller datasets for a faster test run?

Comment thread parquet/src/main/java/org/apache/iceberg/parquet/ParquetWriter.java Outdated
Comment thread parquet/src/test/java/org/apache/iceberg/parquet/TestParquetDataWriter.java Outdated

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

I like this...i can really understand the evaluateRowGroupSize() process on both paths now.

No other suggestions from me

Comment thread parquet/src/test/java/org/apache/iceberg/parquet/TestParquetDataWriter.java Outdated
Comment thread docs/docs/configuration.md Outdated
Comment thread parquet/src/test/java/org/apache/iceberg/parquet/TestParquetDataWriter.java Outdated
Comment thread core/src/main/java/org/apache/iceberg/TableProperties.java Outdated
@nssalian nssalian requested a review from huaxingao June 6, 2026 18:22
Comment thread parquet/src/main/java/org/apache/iceberg/parquet/ParquetWriter.java
@nssalian nssalian requested a review from huaxingao June 7, 2026 02:32

@huaxingao huaxingao 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

@huaxingao huaxingao merged commit e829aaf into apache:main Jun 7, 2026
55 checks passed
@huaxingao

Copy link
Copy Markdown
Contributor

Thanks @nssalian for the PR! Thanks @steveloughran @Fokko for the review!

@nssalian nssalian deleted the fix-parquet-row-group-size branch June 29, 2026 20:32
@nssalian nssalian added this to the Iceberg 1.12.0 milestone Jun 29, 2026
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.

Parquet: Row group size limit not enforced when using GZIP or ZSTD compression

4 participants