1fanwang opened a new pull request, #24838: URL: https://github.com/apache/datafusion/pull/24838
## Which issue does this PR close? - Closes https://github.com/apache/datafusion/issues/22220. ## Rationale for this change `array_position` accepts an optional one-based start position. Passing `-9223372036854775808` currently aborts evaluation with: ```text datafusion/functions-nested/src/position.rs:210:21: attempt to subtract with overflow ``` It now returns the normal execution error `start_from out of bounds: -9223372036854775808`. ## What changes are included in this PR? The one-based-to-zero-based conversion now uses checked subtraction in both optimized and generic execution paths. ## What is the testing strategy for this PR? SQL regressions exercise a scalar start position, a column start position with a scalar needle, and column start and needle values. <details> <summary>Raw results</summary> ```console $ git checkout upstream/main -- datafusion/functions-nested/src/position.rs $ cargo test -p datafusion-sqllogictest --test sqllogictests -- array_position thread 'tokio-rt-worker' panicked at datafusion/functions-nested/src/position.rs:210:21: attempt to subtract with overflow Error: Execution("1 failures") $ git checkout HEAD -- datafusion/functions-nested/src/position.rs $ cargo test -p datafusion-sqllogictest --test sqllogictests -- array_position Running with 12 test threads (available parallelism: 12) Progress: 1/1 files completed (100%) $ RUST_BACKTRACE=1 cargo test --profile ci \ --exclude datafusion-examples --exclude datafusion-benchmarks --exclude datafusion-cli \ --workspace --lib --tests --bins \ --features avro,json,backtrace,extended_tests,recursive_protection,parquet_encryption passed=10997 ignored=8 ``` </details> ## Are there any user-facing changes? Yes. An invalid minimum `Int64` start position returns an execution 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]
