[fix](inverted index) fix is null predicate for inverted index evaluate#56964
[fix](inverted index) fix is null predicate for inverted index evaluate#56964airborne12 merged 2 commits intoapache:masterfrom
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the evaluation of IS NULL predicates when using inverted indexes. The issue was that IS NULL queries were returning incorrect results (0 rows) when relying on inverted index evaluation instead of the expected non-zero counts.
- Corrected the logic in
FunctionIsNull::evaluate_inverted_indexto properly handle null bitmaps - Added comprehensive regression tests to verify IS NULL and NOT (IS NOT NULL) queries work correctly with inverted indexes
- Ensured consistent results between inverted index enabled and disabled modes
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| be/src/vec/functions/is_null.h | Fixed the inverted index evaluation logic for IS NULL predicates by correcting bitmap handling |
| regression-test/suites/inverted_index_p0/test_inverted_is_null.groovy | Added comprehensive test coverage for IS NULL queries with inverted indexes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // null_bitmap is null bitmap | ||
| bitmap_result = segment_v2::InvertedIndexResultBitmap(null_bitmap, null_bitmap); | ||
| } | ||
| if (!index_iter->has_null()) { |
There was a problem hiding this comment.
When the index has no nulls, the function returns OK without setting bitmap_result, but the caller expects a valid bitmap. This could lead to undefined behavior when bitmap_result is accessed later.
| if (!index_iter->has_null()) { | |
| if (!index_iter->has_null()) { | |
| auto empty_bitmap = std::make_shared<roaring::Roaring>(); | |
| bitmap_result = segment_v2::InvertedIndexResultBitmap(empty_bitmap, empty_bitmap); |
| segment_v2::InvertedIndexQueryCacheHandle null_bitmap_cache_handle; | ||
| RETURN_IF_ERROR(index_iter->read_null_bitmap(&null_bitmap_cache_handle)); | ||
| std::shared_ptr<roaring::Roaring> null_bitmap = null_bitmap_cache_handle.get_bitmap(); | ||
| if (!null_bitmap) { |
There was a problem hiding this comment.
Similar to the previous issue, returning OK without setting bitmap_result when null_bitmap is null could cause problems for the caller expecting a valid bitmap result.
| if (!null_bitmap) { | |
| if (!null_bitmap) { | |
| // Set bitmap_result to an empty result if null_bitmap is null | |
| auto empty_bitmap = std::make_shared<roaring::Roaring>(); | |
| bitmap_result = segment_v2::InvertedIndexResultBitmap(empty_bitmap, empty_bitmap); |
|
PR approved by anyone and no changes requested. |
ClickBench: Total hot run time: 30.08 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
|
PR approved by at least one committer and no changes requested. |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run buildall |
TPC-DS: Total hot run time: 189941 ms |
ClickBench: Total hot run time: 30.68 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
PR approved by at least one committer and no changes requested. |
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #50748 #56139
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)