You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scalar index queries handle NOT and NULL incorrectly #4756
Ah, this makes sense because we interpret NOT as the logical inverse. So if value = 1 does not include one then NOT value = 1 will. Not saying this is correct though 😦.
I'm not sure of a simple way to fix it except maybe push NOT down into the indexes themselves instead of handling it a layer above.
I think what we need to do is make scalar queries return something like a nullable selection vector. That way we can process the nulls properly at all stages. Then at the very end we can resolve it to mask.
I think this is how filters work in DataFusion: it takes a nullable Boolean array. Then when filter_record_batch is called it drops null and false.
What is the physical representation of a nullable selection vector? We use roaring bitmaps today which are sparse. Can we introduce nulls without moving to a dense bitmap? Or should we just bite the bullet and move to dense bitmap? Maybe we can implement it as two sparse bitmaps (one of true/false and one of nulls)?
We already represent things intermediately as two sparse bitmaps: allow lists and block lists. So I was thinking it would be natural to add a third null list. We’ll see where that lands me.
If you're working on this, one other optimization I was thinking of making, is removing the "block list and allow list" case. Anytime we have this case we can simply normalize it into a smaller allow list (allow_list = allow_list - block_list ; block_list = None)
If you're working on this, one other optimization I was thinking of making, is removing the "block list and allow list" case. Anytime we have this case we can simply normalize it into a smaller allow list (allow_list = allow_list - block_list ; block_list = None)
Sounds good. I'm thinking:
/// A selection of rows./// /// This is often a result of a filter, where `selected` represents the rows that/// passed the filter, and `nulls` represents the rows where the filter evaluated/// to null. For example, in SQL `NULL > 5` evaluates to null. This is distinct/// from being deselected to support proper three-valued logic for NOT. /// (`NOT FALSE` is TRUE, `NOT TRUE` is FALSE, but `NOT NULL` is NULL.)pubstructRowSelection{pubselected:RowIdTreeMap,pubnulls:RowIdTreeMap,}/// A mask that selects or deselects rows based on an allow-list or block-list.pubenumRowIdMask{AllowList(RowSelection),BlockList(RowSelection),}
Activity
westonpace commentedon Sep 18, 2025
Ah, this makes sense because we interpret NOT as the logical inverse. So if
value = 1does not include one thenNOT value = 1will. Not saying this is correct though 😦.I'm not sure of a simple way to fix it except maybe push NOT down into the indexes themselves instead of handling it a layer above.
refactor: cowardly refuse to use scalar indexes on expressions with n…
wjones127 commentedon Nov 6, 2025
This was accidentally closed by #4815
wjones127 commentedon Nov 17, 2025
I think what we need to do is make scalar queries return something like a nullable selection vector. That way we can process the nulls properly at all stages. Then at the very end we can resolve it to mask.
I think this is how filters work in DataFusion: it takes a nullable Boolean array. Then when
filter_record_batchis called it drops null and false.westonpace commentedon Nov 18, 2025
What is the physical representation of a nullable selection vector? We use roaring bitmaps today which are sparse. Can we introduce nulls without moving to a dense bitmap? Or should we just bite the bullet and move to dense bitmap? Maybe we can implement it as two sparse bitmaps (one of true/false and one of nulls)?
wjones127 commentedon Nov 18, 2025
We already represent things intermediately as two sparse bitmaps: allow lists and block lists. So I was thinking it would be natural to add a third null list. We’ll see where that lands me.
westonpace commentedon Nov 18, 2025
If you're working on this, one other optimization I was thinking of making, is removing the "block list and allow list" case. Anytime we have this case we can simply normalize it into a smaller allow list (allow_list = allow_list - block_list ; block_list = None)
Add infrastructure for null-aware scalar indexes
wjones127 commentedon Nov 19, 2025
Sounds good. I'm thinking:
Add infrastructure for null-aware scalar indexes
Add infrastructure for null-aware scalar indexes
Add infrastructure for null-aware scalar indexes
Add infrastructure for null-aware scalar indexes
fix!: null handling when using `NOT` with scalar indices (#5270)
refactor: cowardly refuse to use scalar indexes on expressions with n…
fix!: null handling when using `NOT` with scalar indices (lance-forma…