alamb opened a new issue, #6701:
URL: https://github.com/apache/arrow-datafusion/issues/6701
### Describe the bug
Calling the `date_trunc(null)` function results in a panic
### To Reproduce
```
DataFusion CLI v26.0.0
❯ select date_trunc('2021-02-01T12:01:02', 'hour');
Optimizer rule 'simplify_expressions' failed
caused by
Arrow error: Parser error: Error parsing timestamp from 'hour': timestamp
must contain at least 10 characters
❯ select date_trunc('hour', '2021-02-01T12:01:02');
+------------------------------------------------------+
| date_trunc(Utf8("hour"),Utf8("2021-02-01T12:01:02")) |
+------------------------------------------------------+
| 2021-02-01T12:00:00 |
+------------------------------------------------------+
1 row in set. Query took 0.074 seconds.
❯ select date_trunc('hour', null);
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value',
/Users/alamb/Software/arrow-datafusion/datafusion/physical-expr/src/datetime_expressions.rs:314:35
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
### Expected behavior
`null` should be returned
### Additional context
Found while reviewing https://github.com/apache/arrow-datafusion/pull/6654
from @Weijun-H
The issue is the use of `unwrap()` in the `date_trunc` implementation
I think this is a good first issue for someone as it involves removing
`unwrap()` and writing some tests using .slt
--
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]