Jefffrey opened a new issue, #21792:
URL: https://github.com/apache/datafusion/issues/21792

   ### Describe the bug
   
   Test cases:
   
   ```sql
   select array_position(haystack, needle, index_from)
   from values
     ([1, 2], 1, 2),
     ([1, 2], 1, null)
   t(haystack, needle, index_from)
   ```
   
   - Currently this fails because `0` is out of bounds, but this is only 
because by default the value underneath a null is usually 0; we can construct 
an array where this isn't the case and pass in a valid in-bounds value even if 
it should be masked by a null
   - This should instead fail by checking nulls, as scalar path also raises 
exec error if it detects a null for the index argument
   
   ```sql
   > select array_position(haystack, needle), array_positions(haystack, needle)
   from values
     ([[1], null], null),
     ([[]], null)
   t(haystack, needle);
   
+-------------------------------------+--------------------------------------+
   | array_position(t.haystack,t.needle) | array_positions(t.haystack,t.needle) 
|
   
+-------------------------------------+--------------------------------------+
   | NULL                                | []                                   
|
   | 1                                   | [1]                                  
|
   
+-------------------------------------+--------------------------------------+
   ```
   
   - This should return `2 | [2]` for the first row and `NULL | []` for the 
second row
   - This is because in the first row, we can find a null element so we return 
that position
   - And for the second row we can't find any null, so we shouldn't return a 
position
   
   ### To Reproduce
   
   _No response_
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to