Skip to content

branch-4.1: [fix](search) Replace ExcludeScorer with null-bitmap-aware version for MUST_NOT to handle NULL rows #61200#61323

Merged
yiguolei merged 1 commit intoapache:branch-4.1from
airborne12:pick/61200-branch-4.1
Mar 14, 2026
Merged

branch-4.1: [fix](search) Replace ExcludeScorer with null-bitmap-aware version for MUST_NOT to handle NULL rows #61200#61323
yiguolei merged 1 commit intoapache:branch-4.1from
airborne12:pick/61200-branch-4.1

Conversation

@airborne12
Copy link
Member

Cherry-pick of #61200 to branch-4.1.

What problem does this PR solve?

Issue Number: close #DORIS-24681

search('NOT msg:omega') incorrectly includes NULL rows in the result set, while NOT search('msg:omega') correctly excludes them.

Root cause: ExcludeScorer does not implement has_null_bitmap() / get_null_bitmap(), inheriting the Scorer base class defaults that always return false / nullptr. This caused NULL documents to be treated as TRUE (matching) rather than NULL, violating SQL three-valued logic where NOT(NULL) = NULL.

Fix: Enhance ExcludeScorer with null bitmap support:

  • Accept a pre-collected exclude_null bitmap (read from index at O(1) cost)
  • Check it during advance()/seek() before the original lazy is_within() exclusion
  • Implement has_null_bitmap()/get_null_bitmap() to propagate null info
  • Plumb binding_keys from function_search.cpp through OccurBooleanQueryBuilder → OccurBooleanQuery → OccurBooleanWeight for proper null bitmap resolution

Release note

Fix search('NOT field:value') incorrectly including NULL rows by using null-bitmap-aware ExcludeScorer.

Check List (For Author)

  • Test
    • Regression test
    • Unit Test
    • Manual test

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

…r MUST_NOT to handle NULL rows (apache#61200)

Cherry-pick of apache#61200 to branch-4.0.

search('NOT msg:omega') incorrectly included NULL rows because ExcludeScorer
did not implement has_null_bitmap()/get_null_bitmap(). Enhanced ExcludeScorer
now accepts a pre-collected exclude_null bitmap and checks it during
advance()/seek() before the original lazy is_within() exclusion.

Key changes:
- ExcludeScorer: add _exclude_null/_null_bitmap members, override
  has_null_bitmap()/get_null_bitmap(), null check in constructor/advance/seek
- OccurBooleanWeight: add build_exclude_opt() to collect null bitmaps from
  MUST_NOT scorers and union them; pass exclude_null to make_exclude()
- Plumb binding_keys from function_search.cpp through OccurBooleanQueryBuilder
  -> OccurBooleanQuery -> OccurBooleanWeight for proper null bitmap resolution
- Add DCHECK for _binding_keys size validation
@airborne12 airborne12 requested a review from yiguolei as a code owner March 13, 2026 12:23
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@airborne12
Copy link
Member Author

run buildall

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 87.84% (65/74) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.94% (19170/36210)
Line Coverage 36.16% (178611/493933)
Region Coverage 32.73% (138221/422270)
Branch Coverage 33.76% (60116/178060)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (74/74) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.45% (25344/35473)
Line Coverage 54.08% (266775/493278)
Region Coverage 51.70% (220591/426662)
Branch Coverage 53.18% (95070/178760)

@yiguolei yiguolei merged commit 867710b into apache:branch-4.1 Mar 14, 2026
21 of 26 checks passed
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