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

   ### Describe the bug
   
   `lead` panics during execution when given `i64::MAX` as the offset. The
   LEAD branch computes `(range.start as i64 - self.shift_offset) as usize`,
   which subtracts past `i64::MIN` when `shift_offset = i64::MAX`.
   
   This is the symmetric case of #22221 (which reports `i64::MIN` panicking
   during planning via negation). The `i64::MAX` value reaches the execution
   path instead, panics with a different message at a different line, so
   filing separately — same area, probably the same fix.
   
   ### To Reproduce
   
   ```sql
   SELECT lead(x, 9223372036854775807) OVER (ORDER BY x ROWS BETWEEN CURRENT 
ROW AND UNBOUNDED FOLLOWING)
   FROM (VALUES (1),(2),(3)) AS t(x);
   ```
   
   ### Actual behavior
   
   ```text
   thread 'main' panicked at datafusion/functions-window/src/lead_lag.rs:556:13:
   attempt to subtract with overflow
   ```
   
   ### Expected behavior
   
   Return an execution error for an invalid offset, not a panic.
   
   ### Notes
   
   Source: 
https://github.com/apache/datafusion/blob/53.1.0/datafusion/functions-window/src/lead_lag.rs#L556
   
   Found via LLM-guided fuzz testing on DataFusion 53.1.0.
   


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