[ https://issues.apache.org/jira/browse/HIVE-27673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17765527#comment-17765527 ]
Stamatis Zampetakis commented on HIVE-27673: -------------------------------------------- I updated the wiki to reflect the changes in date_format and hive.datetime.formatter property: * https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF * https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties#ConfigurationProperties-Datetime > Configurable datetime formatter for date_format > ----------------------------------------------- > > Key: HIVE-27673 > URL: https://issues.apache.org/jira/browse/HIVE-27673 > Project: Hive > Issue Type: Improvement > Components: HiveServer2 > Affects Versions: 4.0.0-beta-1 > Reporter: Stamatis Zampetakis > Assignee: Stamatis Zampetakis > Priority: Major > Labels: pull-request-available > Fix For: 4.0.0 > > > HIVE-25268 switched the internal implementation of date_format from > java.text.SimpleDateFormat to java.time.format.DateTimeFormatter in order to > avoid some inconsistencies (arguably wrong results) for dates prior to 1900. > However, the API of the underlying formatter is exposed to the user since > they need to pass patterns that are valid for the respective formatter. > Changing the formatter implementation resolves the bugs in HIVE-25268 but > also leads to backward incompatible behavior. > Consider for example the following query where the letter 'u' is used to > format the date: > {code:sql} > select date_format('2023-09-08','u'); > {code} > The query above will return different result depending on the formatter that > is used underneath. > In > [SimpleDateFormat|https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html], > the letter 'u' means day of the week so the query returns 5. > In > [DateTimeFormatter|https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html], > the letter 'u' means year so the query returns 2023. > The goal of this ticket is to make the underlying formatter of date_format > function configurable by the end-user via property, similarly to what was > done in HIVE-25576. For this purpose we could reuse the same property: > hive.datetime.formatter -- This message was sent by Atlassian Jira (v8.20.10#820010)