alamb opened a new issue, #7118: URL: https://github.com/apache/arrow-datafusion/issues/7118
### Describe the bug Panic: `index out of bounds: the len is 0 but the index is 0` in `first_value` / `last_value` when used as an aggregate ### To Reproduce ```sql create table foo (x int) as values (1), (2); select last_value(x) from foo; ``` Result: ```shell (arrow_dev) alamb@MacBook-Pro-8:~/Software/influxdb_iox2$ datafusion-cli DataFusion CLI v28.0.0 ❯ create table foo (x int) as values (1), (2); 0 rows in set. Query took 0.003 seconds. ❯ select last_value(x) from foo; thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/alamb/Software/arrow-datafusion/datafusion/physical-expr/src/aggregate/first_last.rs:374:13 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` These other queries panic: ``` 0 rows in set. Query took 0.003 seconds. ❯ select last_value(x) from foo GROUP BY x; thread 'thread 'tokio-runtime-workertokio-runtime-worker' panicked at '' panicked at 'index out of bounds: the len is 0 but the index is 0index out of bounds: the len is 0 but the index is 0', ', /Users/alamb/Software/arrow-datafusion/datafusion/physical-expr/src/aggregate/first_last.rs/Users/alamb/Software/arrow-datafusion/datafusion/physical-expr/src/aggregate/first_last.rs::374374::1313 ❯ select first_value(x) from foo GROUP BY x; thread 'thread 'tokio-runtime-workertokio-runtime-worker' panicked at '' panicked at 'index out of bounds: the len is 0 but the index is 0index out of bounds: the len is 0 but the index is 0', ', /Users/alamb/Software/arrow-datafusion/datafusion/physical-expr/src/aggregate/first_last.rs/Users/alamb/Software/arrow-datafusion/datafusion/physical-expr/src/aggregate/first_last.rs:189::13189 :note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` ### Expected behavior query should run successfully ### Additional context _No response_ -- 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]
