Skip to content

Fixing #16489 bug - NULL value searching in list_position#16969

Closed
RadimBaca wants to merge 2 commits intoduckdb:mainfrom
RadimBaca:list_position_fixing_#16489
Closed

Fixing #16489 bug - NULL value searching in list_position#16969
RadimBaca wants to merge 2 commits intoduckdb:mainfrom
RadimBaca:list_position_fixing_#16489

Conversation

@RadimBaca
Copy link
Contributor

The fix contains several changes:

  1. Implicit cast from NULL to list in list_position is not allowed. list_position(NULL, _) invokes an exception contains_or_position.cpp.
  2. The validity mask is reset before the BinaryExecutor::ExecuteWithNulls call in the ListSearchSimpleOp function. We store a copy of the validity mask in target_mask, and it is then used in the list search.
  3. Tests are changed to reflect the new behavior.

@Mytherin Mytherin requested a review from maiadegraaf April 11, 2025 06:42
@maiadegraaf
Copy link
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
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.

2 participants