Fixing #16489 bug - NULL value searching in list_position#16969
Closed
RadimBaca wants to merge 2 commits intoduckdb:mainfrom
Closed
Fixing #16489 bug - NULL value searching in list_position#16969RadimBaca wants to merge 2 commits intoduckdb:mainfrom
RadimBaca wants to merge 2 commits intoduckdb:mainfrom
Conversation
Contributor
|
Thanks for the contribution! This is a good start, but the implementation differs quite a bit from what we're aiming for, and guiding the necessary changes would be quite involved. To move things forward more efficiently, I’ve opened a follow-up PR that builds on this one and implements the behavior we’re looking for: #17080. Thanks again for your work! |
Mytherin
added a commit
that referenced
this pull request
May 7, 2025
…7080) Previously, when calling `list_position([1, 2, 3, NULL], NULL)`, the function would always return `NULL` instead of the index of the `NULL` element. This behavior differed from PostgreSQL. This PR fixes the issue, so that `list_position` now correctly returns the index of the element, regardless of whether or not it is `NULL`. This PR builds on: #16969 Fixes: #16489
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.
The fix contains several changes:
NULLto list inlist_positionis not allowed.list_position(NULL, _)invokes an exception contains_or_position.cpp.BinaryExecutor::ExecuteWithNullscall in theListSearchSimpleOpfunction. We store a copy of the validity mask intarget_mask, and it is then used in the list search.