Skip to content

[common] Skip null literals in btree global index IN predicates - #9624

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:fix/globalindex-visitin-null
Open

[common] Skip null literals in btree global index IN predicates#9624
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:fix/globalindex-visitin-null

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

close #9623

BTreeIndexReader.visitIn fed every literal in the list straight into rangeQuery, which serializes the key and compares it, so a null literal threw a NullPointerException and took the scan with it. IN never matches NULL, so the literal should just be skipped.

Every other reader in that package already does this. globalindex/bitmap/BitmapIndexReader null-checks inside its own in loop, and its equal, lessThan, greaterThan, between, notEqual and notIn do 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.visitIn already 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.testInPredicateWithNullLiteral runs for every reader in that hierarchy, so BTreeIndexReaderTest and LazyFilteredBTreeIndexReaderTest both 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 test on JDK 8: 228 tests, 0 failures. spotless:check and checkstyle:check on paimon-common are clean.

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.
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.

[Bug] A NULL inside an IN list NPEs the btree global index reader

1 participant