Skip to content

feat(parquet): add Bloom row-group pruning - #1114

Open
zhjwpku wants to merge 7 commits into
apache:mainfrom
zhjwpku:feat/parquet-bloom-row-group-filter
Open

zhjwpku wants to merge 7 commits into
apache:mainfrom
zhjwpku:feat/parquet-bloom-row-group-filter

Conversation

@zhjwpku

@zhjwpku zhjwpku commented Nov 12, 2026

Copy link
Copy Markdown
Member

Evaluate EQ and IN predicates with Arrow's Bloom reader after footer statistics, following Java Iceberg's inclusive filtering rules. Keep other predicates, missing columns and files without usable field IDs or Bloom metadata inclusive.

Hash literals using the file's physical representation, including numeric promotions, temporal types, decimal precision and width, binary/fixed and UUID values. Cache each column's Bloom filter per row group and load only Bloom payloads during planning. Preserve split selection, file-relative row positions and inherited row IDs after pruning.

BloomVisitor visitor(manifest, row_group, bloom_reader, field_id_to_column_idx_);
return Visit<bool>(bound_, visitor);
} catch (const ::parquet::ParquetException& e) {
return Invalid("Cannot read Parquet Bloom filter: {}", e.what());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we fail on this path? Might it still match?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The row group may still match, so a Bloom read failure must never be treated as a negative match. This path returns an error and aborts the read, matching Java‘s behavior when an advertised Bloom filter cannot be loaded. Missing Bloom metadata still returns “might match”.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Parquet permits a 96-byte split-block bitset, and parquet-go produces one for 60 values at 10 bits per value. Arrow C++ 25 rejects that length, so this turns a valid file into an Open failure. Please retain the group for this layout or use a reader that accepts it, and cover it with a cross-writer fixture. Parquet block-count rule · Arrow length check

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I currently re-read the header to distinguish a valid 96-byte bitset from a malformed one. Would you prefer to skip Bloom pruning for that column whenever Arrow reports this length error, even if the bitset is malformed?

Comment thread src/iceberg/parquet/parquet_reader.cc Outdated
auto should_read, stats_filter_->ShouldRead(reader_->manifest(), *row_group));
if (should_read && bloom_filter_) {
auto bloom_reader =
reader_->parquet_reader()->GetBloomFilterReader().RowGroup(row_group_index);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can throw uncaught.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. I've included GetBloomFilterReader().RowGroup(...) in the try/catch and convert ParquetException to an Iceberg error.

@manuzhang

manuzhang commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

@zhjwpku Thanks for the PR. I've left some comments inline. BTW, is there a flag to switch on/off this feature?

@zhjwpku

zhjwpku commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

@zhjwpku Thanks for the PR. I've left some comments inline. BTW, is there a flag to switch on/off this feature?

Yeah, maybe we should have some handles for these pruning, let me check how the java impl deal with this.

@zhjwpku

zhjwpku commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

@zhjwpku Thanks for the PR. I've left some comments inline. BTW, is there a flag to switch on/off this feature?

Yeah, maybe we should have some handles for these pruning, let me check how the java impl deal with this.

We have a read.parquet.row-group-filter.enabled option, setting it to false disables both footer-statistics and Bloom row-group pruning.

@zhjwpku
zhjwpku force-pushed the feat/parquet-bloom-row-group-filter branch from cf2cdda to 45db09e Compare November 22, 2026 15:58
number = std::get<int64_t>(value.value());
break;
case TypeId::kDecimal:
number = std::get<Decimal>(value.value()).value();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A pre-bound EQ can compare a scale-1 literal 5.0 with a scale-2 column containing 5.00. Row evaluation finds a match, but this hashes 50 while the file hashed 500. Please check the literal scale before probing any decimal encoding and cover this through the pre-bound reader path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed, if they differ, we keep the row group.


Result<bool> In(const std::shared_ptr<Bound>& expr,
const BoundSetPredicate::LiteralSet& values) override {
if (std::ranges::any_of(values, [](const auto& value) { return value.IsNaN(); })) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This scans every IN literal for each candidate row group, even for an integer column without a Bloom filter. Could we compute the NaN flag once when preparing the predicate?

Evaluate EQ and IN predicates with Arrow's Bloom reader after footer
statistics, following Java Iceberg's inclusive filtering rules. Keep
other predicates, missing columns and files without usable field IDs or
Bloom metadata inclusive.

Hash literals using the file's physical representation, including numeric
promotions, temporal types, decimal precision and width, binary/fixed and
UUID values. Cache each column's Bloom filter per row group and load only
Bloom payloads during planning. Preserve split selection, file-relative
row positions and inherited row IDs after pruning.
Check decimal scale before hashing and prepare NaN membership predicates once per file. Retain columns with whole-block plaintext Bloom bitsets that Arrow 25 rejects while propagating malformed filters and read errors.
@zhjwpku
zhjwpku force-pushed the feat/parquet-bloom-row-group-filter branch from 4fb3d66 to 574fd91 Compare November 28, 2026 12:20
@zhjwpku
zhjwpku requested review from manuzhang and wgtmac November 29, 2026 02:39

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants