Sean-Kenneth-Doherty opened a new pull request, #22291: URL: https://github.com/apache/datafusion/pull/22291
## Which issue does this PR close? - Closes #22220. ## Rationale for this change `array_position` converts the optional 1-indexed `start_from` argument to a 0-indexed offset by subtracting one. When `start_from` is `i64::MIN`, that subtraction can underflow and panic before DataFusion can return a normal error. ## What changes are included in this PR? - Adds a shared checked conversion for `array_position` `start_from` values. - Uses it in both scalar and array `start_from` paths. - Adds regression coverage for the `i64::MIN` boundary. ## Are these changes tested? - `cargo fmt --all` - `TMPDIR=/home/sean/Projects/datafusion-array-position-min/target/tmp cargo test -p datafusion-functions-nested position::tests::test_array_position_start_from_min_value -- --nocapture` - `TMPDIR=/home/sean/Projects/datafusion-array-position-min/target/tmp cargo test --profile=ci --test sqllogictests -- array/array_position.slt` - `TMPDIR=/home/sean/Projects/datafusion-array-position-min/target/tmp cargo clippy --all-targets --all-features -- -D warnings` - `git diff --check` I also manually checked the issue reproducer no longer panics: `EXPLAIN SELECT array_position([1], 1, -9223372036854775808);` now returns a plan, while plain execution returns `Execution error: start_from out of bounds: -9223372036854775808`. ## Are there any user-facing changes? Invalid `array_position` `start_from` values at the `i64::MIN` boundary now return a normal DataFusion error instead of panicking. -- 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]
