[GLUTEN-11708][VL] Translate might_contain as a subfield filter for scan-level bloom filter pushdown#11711
[GLUTEN-11708][VL] Translate might_contain as a subfield filter for scan-level bloom filter pushdown#11711acvictor wants to merge 4 commits intoapache:mainfrom
Conversation
afcb288 to
15f1a6f
Compare
15f1a6f to
0258168
Compare
|
@zhztheplayer can you please review this PR? |
| try { | ||
| evaluator->evaluate(exprSet.get(), rows, input, result); | ||
| } catch (const VeloxUserError&) { | ||
| return nullptr; | ||
| } |
There was a problem hiding this comment.
Errors are intentionally swallowed because a non-evaluable expression simply means the filter cannot be pushed down. So if the filter cannot be pushed down, leafCallToSubfieldFilter returns std::nullopt, and Velox will evaluate might_contain as a regular post-scan expression which is the same behavior as before. Does this flow make sense? I have updated the comment as well.
There was a problem hiding this comment.
In which case it cannot be pushed? Can you paste the error here?
There was a problem hiding this comment.
I don't actually have an example, but I have used the same pattern as toConstant() helper in Velox ExprToSubfieldFilter.cpp which is used by makeEqualFilter, makeLessThanFilter, and other filter factories https://github.com/facebookincubator/velox/blob/main/velox/expression/ExprToSubfieldFilter.cpp#L27
| } | ||
|
|
||
| /// Filter backed by Velox's BloomFilter<> serialized data from bloom_filter_agg. | ||
| class SparkBloomFilter final : public common::Filter { |
There was a problem hiding this comment.
Let's use SparkMightContain or so to align with Spark's function name.
| serializedData_(std::move(serializedData)) {} | ||
|
|
||
| bool testInt64(int64_t value) const final { | ||
| return BloomFilter<>::mayContain(serializedData_.data(), folly::hasher<int64_t>()(value)); |
There was a problem hiding this comment.
We can create a bloom filter object as class member, since bloomFilter.mayContain is faster than BloomFilter<>::mayContain.
zhztheplayer
left a comment
There was a problem hiding this comment.
Thanks. Code LGTM, will take some time to test
| try { | ||
| evaluator->evaluate(exprSet.get(), rows, input, result); | ||
| } catch (const VeloxUserError&) { | ||
| return nullptr; | ||
| } |
There was a problem hiding this comment.
In which case it cannot be pushed? Can you paste the error here?
What changes are proposed in this pull request?
This PR adds support for pushing
might_contain(bloomFilter, value) down into Velox's subfield filter system viaSparkExprToSubfieldFilterParser. Previously,might_containwas evaluated as a post-scan expression. With this change, the bloom filter check can be applied at the storage scan level allowing entire row groups to be skipped before data is fully decoded.Velox has two incompatible bloom filter implementations:
bloom_filter_agg/might_contain(groups-of-64-bits, 4 hash functions)BigintValuesUsingBloomFilterfilter class (SIMD split-block)Since these are not interchangeable, a new
SparkBloomFilterfilter class is introduced that wraps the serializedBloomFilter<>data and implementstestInt64()usingBloomFilter<>::mayContain()withfolly::hasher<int64_t>() which is the same code path used by the JNImightContainLongOnSerializedBloom.How was this patch tested?
Added new test suite covering basic filtering, null bloom filter, negation, non-column value, range test, and clone behavior.
Was this patch authored or co-authored using generative AI tooling?
No
Related issue #11708