friendlymatthew commented on issue #14536: URL: https://github.com/apache/datafusion/issues/14536#issuecomment-2667388287
> @Omega359 wrote: We submit a PR to arrow-rs to attempt the casting of dates to timestamps in the display code in arrow-cast upon receiving a format failure. I also think this is the most sound. The error is occurring [here](https://github.com/apache/arrow-rs/blob/38d6e691f4ee1b356f28d77b6820de67166c51c3/arrow-cast/src/display.rs#L557). We hand off the formatting task to `chrono` which attempts to format a [`NaiveDate`](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDate.html#method.format) with the supplied format string. If the format string contains [time-related specifiers](https://docs.rs/chrono/latest/chrono/format/strftime/index.html), the format attempt will panic. To format both date and time, one would use `chrono`'s `NaiveDateTime` instead. - Arrow-wise, if the initial `Date` formatting fails, we should perform an intermediary cast from `Date` to `Timestamp` and reapply the format string. Here's the issue: https://github.com/apache/arrow-rs/issues/7153 - Datafusion-wise, once this feature above lands, I'll follow up with some SLT test cases. <br> > @alamb wrote: maybe we should make the error message better? Consider a query with a malformed format string: ```sql > select to_char('2023-09-04'::date, '%Y-%m-%k'); Execution error: Cast error: Format error ``` I think we can benefit from a more detailed error message. But fwiw, I think this is a `chrono` issue, as the `write!()` error upon format is very vague. I've opened an issue to address this: https://github.com/chronotope/chrono/issues/1660. __ **TL;DR:** We can't format a `Date` with time-related specifiers in `chrono`. We should perform an intermediary cast to `Timestamp` in arrow. Formatting error messages are vague, and we could benefit from capturing more context in the error message. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org