xiedeyantu opened a new pull request, #22304:
URL: https://github.com/apache/datafusion/pull/22304

   ## Which issue does this PR close?
   
   - Closes #22222.
   
   ## Rationale for this change
   
   `nth_value` could panic at execution time when called with `i64::MIN` as the 
`n` argument. The implementation supports negative `n` for reverse indexing and 
negated the value internally, but negating `i64::MIN` overflows. This caused a 
runtime panic instead of returning a normal DataFusion error for invalid input.
   
   ## What changes are included in this PR?
   
   This PR adds validation for the second argument of `nth_value` so that 
`i64::MIN` is rejected before any negation occurs. Instead of panicking during 
execution, the function now returns a regular execution error.
   
   This PR also adds regression coverage at two levels:
   - a unit test for the `nth_value` window function implementation
   - a sqllogictest case covering the SQL query shape that previously triggered 
the panic
   
   ## Are these changes tested?
   
   Yes.
   
   The change is covered by:
   1. a focused unit test in the window function implementation
   2. a SQL logic test in `window.slt`
   
   Validated with:
   1. `cargo test -p datafusion-functions-window nth_value --lib`
   2. `cargo test -p datafusion-sqllogictest --test sqllogictests window`
   
   ## Are there any user-facing changes?
   
   Yes. Queries that previously panicked when calling `nth_value(..., 
-9223372036854775808)` now return a proper execution error instead.


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