jiwen624 opened a new pull request, #56388:
URL: https://github.com/apache/spark/pull/56388

   ### What changes were proposed in this pull request?
   Widen the index to `Long` in `ElementAt`'s bounds check (interpreted eval, 
codegen, and the `nullability` helper) and in 
`ArrayExpressionUtils.resolveArrayIndex` (ANSI path), so an `Int.MinValue` 
index is correctly detected as out of bounds.
   
   ### Why are the changes needed?
   `element_at(arr, Int.MinValue)` leaks an internal 
`IndexOutOfBoundsException` instead of returning `NULL` (non-ANSI) or raising 
`INVALID_ARRAY_INDEX_IN_ELEMENT_AT` (ANSI), and `try_element_at` throws despite 
its no-throw contract. 
   **Root cause**: `Math.abs(Int.MinValue)` wraps back to a negative value, 
bypassing the out-of-bounds guard. 
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. element_at/try_element_at with an Int.MinValue index now return NULL 
(non-ANSI) or raise the documented INVALID_ARRAY_INDEX_IN_ELEMENT_AT error 
(ANSI) instead of leaking an internal exception.
   
   ### How was this patch tested?
   New test case added
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Yes. Claude Code


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