Repository navigation
test(parquet): add I/O tracking test for Bloom filter loading baseline #26897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alamb
merged 9 commits into
apache:main
from
mohitgurav20:test/parquet-bloom-filter-io-baseline
Nov 3, 2026
+415
−0
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c0a70fb
test(parquet): add SQL-level I/O snapshot test for Bloom filter loadi…
mohitgurav20 73ba64e
test(parquet): use inline snapshot for Bloom filter I/O test
alamb 37110ee
test(parquet): move I/O tracing setup into parquet/io module
alamb a6a9426
Rework tests
alamb 61f0e9d
Merge remote-tracking branch 'apache/main' into alamb/pr-26897-io-ref…
alamb 1522d2c
test(parquet): complete comment on pruned Bloom filter I/O test
alamb f1517f6
comments
alamb 2fa72b0
note where similar tests are
alamb 606ab3f
Merge branch 'main' into test/parquet-bloom-filter-io-baseline
mohitgurav20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership | ||
| // SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements | ||
|
|
||
| //! Tests tracking storage I/O events during Parquet Bloom filter evaluation. | ||
|
|
||
| use std::sync::Arc; | ||
|
|
||
| use arrow::array::{ArrayRef, Int32Array, RecordBatch}; | ||
| use bytes::Bytes; | ||
| use datafusion::prelude::SessionConfig; | ||
| use insta::assert_snapshot; | ||
| use parquet::arrow::ArrowWriter; | ||
| use parquet::file::properties::{EnabledStatistics, WriterProperties}; | ||
|
|
||
| use super::ParquetIoTest; | ||
|
|
||
| /// Matching row group | ||
| #[tokio::test] | ||
| async fn test_parquet_bloom_filter_io_matching() { | ||
| let test = bloom_filter_test().await; | ||
| // Loads the Bloom filters, finds a match, then reads the data pages and | ||
| // produces a batch. | ||
| assert_snapshot!(test.query("SELECT * FROM t WHERE a = 10 AND b = 100").await, @r" | ||
| --- Query: SELECT * FROM t WHERE a = 10 AND b = 100 (1 rows) --- | ||
| Read Parquet footer (offsets 0..678) | ||
| Read OffsetIndex for column 'a' (rg 0) (offsets 192..213) | ||
| Read Bloom filter for column 'a' (rg 0) (offsets 98..145) | ||
| Read Bloom filter for column 'b' (rg 0) (offsets 145..192) | ||
| Read data page for column 'a' (rg 0) (offsets 4..51) | ||
| Read data page for column 'b' (rg 0) (offsets 51..98) | ||
| Produce batch (1 rows) | ||
| "); | ||
| } | ||
|
|
||
| /// Column `a` does not match, so the row group is pruned. | ||
| #[tokio::test] | ||
| async fn test_parquet_bloom_filter_io_pruned() { | ||
| let test = bloom_filter_test().await; | ||
| // Currently the Bloom filters for all candidate columns (`a` and `b`) are | ||
| // loaded upfront. With incremental pruning | ||
| // (https://github.com/apache/datafusion/issues/25811), `a` would be | ||
| // evaluated first and the Bloom filter for `b` would not be loaded. | ||
| assert_snapshot!(test.query("SELECT * FROM t WHERE a = 999 AND b = 100").await, @r" | ||
| --- Query: SELECT * FROM t WHERE a = 999 AND b = 100 (0 rows) --- | ||
| Read Parquet footer (offsets 0..678) | ||
| Read OffsetIndex for column 'a' (rg 0) (offsets 192..213) | ||
| Read Bloom filter for column 'a' (rg 0) (offsets 98..145) | ||
| Read Bloom filter for column 'b' (rg 0) (offsets 145..192) | ||
| "); | ||
| } | ||
|
|
||
| /// Returns a [`ParquetIoTest`] for a file with one row group of 3 rows: | ||
| /// | ||
| /// | a | b | | ||
| /// |----|-----| | ||
| /// | 10 | 100 | | ||
| /// | 20 | 200 | | ||
| /// | 30 | 300 | | ||
| /// | ||
| /// Both columns have Bloom filters. Statistics are disabled so that row group | ||
| /// pruning relies entirely on the Bloom filters. | ||
| async fn bloom_filter_test() -> ParquetIoTest { | ||
| let a: ArrayRef = Arc::new(Int32Array::from(vec![10, 20, 30])); | ||
| let b: ArrayRef = Arc::new(Int32Array::from(vec![100, 200, 300])); | ||
| let batch = RecordBatch::try_from_iter([("a", a), ("b", b)]).unwrap(); | ||
|
|
||
| let props = WriterProperties::builder() | ||
| .set_max_row_group_row_count(Some(3)) | ||
| .set_bloom_filter_enabled(true) | ||
| .set_statistics_enabled(EnabledStatistics::None) | ||
| .build(); | ||
|
|
||
| let mut buffer = Vec::new(); | ||
| let mut writer = | ||
| ArrowWriter::try_new(&mut buffer, batch.schema(), Some(props)).unwrap(); | ||
| writer.write(&batch).unwrap(); | ||
| writer.close().unwrap(); | ||
|
|
||
| let config = SessionConfig::new() | ||
| .with_target_partitions(1) | ||
| .with_parquet_bloom_filter_pruning(true); | ||
|
|
||
| ParquetIoTest::new(Bytes::from(buffer), config).await | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am biased, but quite pleased with this test - it shows clearly the IO pattern of the reader