friendlymatthew opened a new pull request, #15361:
URL: https://github.com/apache/datafusion/pull/15361
   Closes https://github.com/apache/datafusion/issues/14536
   
   ## Rationale for this change
   
   Datafusion currently errs when attempting to format a date using 
time-related specifiers. 
   
   ```sql
   > select to_char('2023-09-04'::date, '%Y-%m-%dT%H:%M:%S%.3f');
   Execution error: Cast error: Format error
   ```
   
   However, Postgres supports this feature as it implicitly treats the date as 
a timestamp. 
   
   Rather than eagerly casting every `Date32` to a `Date64` when calling 
`to_char`, this commit attempts to first format a `Date32` with the supplied 
format string. If the formatting fails, we try to reformat as a `Date64`. 
   
   This way, only format strings with time-related specifiers endure the 
intermediary cast. 
   
   ## What changes are included in this PR?
   
   All changes are tested, specifically for two different call sites: 
`_to_char_scalar` and `_to_char_array`.
   


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

Reply via email to