[common] Skip null literals in btree global index IN predicates - #9624
Open
LuciferYang wants to merge 1 commit into
Open
[common] Skip null literals in btree global index IN predicates#9624LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
BTreeIndexReader.visitIn passed every literal to rangeQuery, which serializes the key, so a null literal in an IN list threw a NullPointerException and failed the scan. IN never matches NULL, so skip it, which is what the sibling bitmap global index reader already does in its own in loop.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
close #9623
BTreeIndexReader.visitInfed every literal in the list straight intorangeQuery, which serializes the key and compares it, so a null literal threw aNullPointerExceptionand took the scan with it.INnever matches NULL, so the literal should just be skipped.Every other reader in that package already does this.
globalindex/bitmap/BitmapIndexReadernull-checks inside its owninloop, and itsequal,lessThan,greaterThan,between,notEqualandnotIndo the same. The guard therefore goes in the same place, in the leaf, and the btree reader stops being the odd one out.The file selector is unaffected:
SortedFileMetaSelector.visitInalready skips nulls when it decides which index files overlap, so a list of only nulls selects no file and the result is empty without any special case for it.Tests
AbstractIndexReaderTest.testInPredicateWithNullLiteralruns for every reader in that hierarchy, soBTreeIndexReaderTestandLazyFilteredBTreeIndexReaderTestboth pick it up. It checks the two shapes that matter: a list mixing a real key with a null returns exactly the rows for the real key, and a list of only nulls returns an empty result.Against the unfixed reader all 12 template instances of that test fail with a
NullPointerException.mvn -pl paimon-common -Dtest=BTreeIndexReaderTest,LazyFilteredBTreeIndexReaderTest teston JDK 8: 228 tests, 0 failures.spotless:checkandcheckstyle:checkon paimon-common are clean.