You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2023/09/08 08:09:00 UTC

[jira] [Created] (HIVE-27673) Configurable datetime formatter for date_format

Stamatis Zampetakis created HIVE-27673:
------------------------------------------

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


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)