You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "lyne7-sc (via GitHub)" <gi...@apache.org> on 2026/06/17 13:00:12 UTC
[PR] fix: Parquet bloom filter pruning can incorrectly filter decimals encoded as FIXED_LEN_BYTE_ARRAY [datafusion]
lyne7-sc opened a new pull request, #22995:
URL: https://github.com/apache/datafusion/pull/22995
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #22994.
## Rationale for this change
Parquet bloom filter pruning can incorrectly prune decimal columns encoded as `FIXED_LEN_BYTE_ARRAY`.
Bloom filters are checked against the physical bytes stored in the Parquet file. For `FIXED_LEN_BYTE_ARRAY`, the byte width comes from the Parquet column descriptor's `type_length`. DataFusion was checking decimal literals using a fixed-width integer byte representation, which can differ from thefile's fixed byte width and cause false negatives.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
- Carry the Parquet column `type_length` together with the bloom filter metadata.
- Use `type_length` when checking decimal literals against `FIXED_LEN_BYTE_ARRAY` bloom filters.
- Fall back to conservative pruning behavior when the fixed byte length cannot be represented safely.
- Add a regression test for fixed-length decimal bloom filter pruning.
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
Yes.
## Are there any user-facing changes?
No API changes. This fixes incorrect query results when Parquet bloom filter pruning is enabled for fixed-length decimal columns.
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Parquet bloom filter pruning can incorrectly filter decimals encoded as FIXED_LEN_BYTE_ARRAY [datafusion]
Posted by "lyne7-sc (via GitHub)" <gi...@apache.org>.
lyne7-sc commented on code in PR #22995:
URL: https://github.com/apache/datafusion/pull/22995#discussion_r3442438941
##########
datafusion/datasource-parquet/src/bloom_filter.rs:
##########
@@ -375,6 +409,40 @@ mod tests {
.await
}
+ #[tokio::test]
+ async fn test_row_group_bloom_filter_pruning_predicate_decimal128() {
Review Comment:
Added a negative Decimal128 regression test using values from -100 to -600 and verifying `decimal_col = -500` keeps only the matching row group.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Parquet bloom filter pruning can incorrectly filter decimals encoded as FIXED_LEN_BYTE_ARRAY [datafusion]
Posted by "lyne7-sc (via GitHub)" <gi...@apache.org>.
lyne7-sc commented on PR #22995:
URL: https://github.com/apache/datafusion/pull/22995#issuecomment-4751520130
@kosiew Thanks for the review! I’ve addressed the comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Parquet bloom filter pruning can incorrectly filter decimals encoded as FIXED_LEN_BYTE_ARRAY [datafusion]
Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew merged PR #22995:
URL: https://github.com/apache/datafusion/pull/22995
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Parquet bloom filter pruning can incorrectly filter decimals encoded as FIXED_LEN_BYTE_ARRAY [datafusion]
Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew commented on code in PR #22995:
URL: https://github.com/apache/datafusion/pull/22995#discussion_r3434531839
##########
datafusion/datasource-parquet/src/bloom_filter.rs:
##########
@@ -39,7 +39,8 @@ pub(crate) struct BloomFilterStatistics {
/// Value:
/// * [`Sbbf`] (Bloom filter),
/// * Parquet physical [`Type`] needed to evaluate literals against the filter
- column_sbbf: HashMap<String, (Sbbf, Type)>,
+ /// * Type length from the Parquet column descriptor
+ column_sbbf: HashMap<String, (Sbbf, Type, i32)>,
Review Comment:
This tuple now carries a pretty important `type_length` contract. A small named struct, such as `struct ColumnBloomFilter { sbbf: Sbbf, physical_type: Type, type_length: i32 }`, could make the invariant clearer and help avoid accidentally mixing up tuple fields at call sites.
##########
datafusion/datasource-parquet/src/bloom_filter.rs:
##########
@@ -375,6 +409,40 @@ mod tests {
.await
}
+ #[tokio::test]
+ async fn test_row_group_bloom_filter_pruning_predicate_decimal128() {
Review Comment:
Nice regression coverage for the fixed-width truncation path. It might be worth adding a negative decimal case as well, since Parquet fixed-len decimal bytes depend on two's-complement sign extension and truncation. For example, you could write row groups with negative values and assert that a predicate like `decimal_col = -500` keeps only the matching row group.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Parquet bloom filter pruning can incorrectly filter decimals encoded as FIXED_LEN_BYTE_ARRAY [datafusion]
Posted by "lyne7-sc (via GitHub)" <gi...@apache.org>.
lyne7-sc commented on code in PR #22995:
URL: https://github.com/apache/datafusion/pull/22995#discussion_r3442441949
##########
datafusion/datasource-parquet/src/bloom_filter.rs:
##########
@@ -39,7 +39,8 @@ pub(crate) struct BloomFilterStatistics {
/// Value:
/// * [`Sbbf`] (Bloom filter),
/// * Parquet physical [`Type`] needed to evaluate literals against the filter
- column_sbbf: HashMap<String, (Sbbf, Type)>,
+ /// * Type length from the Parquet column descriptor
+ column_sbbf: HashMap<String, (Sbbf, Type, i32)>,
Review Comment:
Addressed by replacing the tuple with a `ColumnBloomFilter` struct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org