You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2019/06/05 16:07:02 UTC

[jira] [Commented] (IMPALA-7369) Implement DATE builtin functions

    [ https://issues.apache.org/jira/browse/IMPALA-7369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16856815#comment-16856815 ] 

ASF subversion and git services commented on IMPALA-7369:
---------------------------------------------------------

Commit f0678b06e64b57e0b26ca73577444e1941925dbc in impala's branch refs/heads/master from Attila Jeges
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=f0678b0 ]

IMPALA-7369: part 1: Implement TRUNC, DATE_TRUNC, EXTRACT, DATE_PART functions for DATE

These functions are somewhat similar in that each of them takes a DATE
argument and a time unit to work with.

They work identically to the corresponding TIMESTAMP functions. The
only difference is that the DATE functions don't accept time-of-day
units.

TRUNC(DATE d, STRING unit)
Truncates a DATE value to the specified time unit. The 'unit' argument
is case insensitive. This argument string can be one of:
  SYYYY, YYYY, YEAR, SYEAR, YYY, YY, Y: Year.
  Q: Quarter.
  MONTH, MON, MM, RM: Month.
  DDD, DD, J: Day.
  DAY, DY, D: Starting day (Monday) of the week.
  WW: Truncates to the most recent date, no later than 'd', which is
      on the same day of the week as the first day of year.
  W: Truncates to the most recent date, no later than 'd', which is on
     the same day of the week as the first day of month.

The impelementation mirrors Impala's TRUNC(TIMESTAMP ts, STRING unit)
function. Hive and Oracle SQL have a similar function too.
Reference:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions201.htm
.

DATE_TRUNC(STRING unit, DATE d)
Truncates a DATE value to the specified precision. The 'unit' argument
is case insensitive. This argument string can be one of: DAY, WEEK,
MONTH, YEAR, DECADE, CENTURY, MILLENNIUM.

The implementation mirrors Impala's DATE_TRUNC(STRING unit,
TIMESTAMP ts) function. Vertica has a similar function too.
Reference:
https://my.vertica.com/docs/8.1.x/HTML/index.htm#Authoring/
    SQLReferenceManual/Functions/Date-Time/DATE_TRUNC.htm
.

EXTRACT(DATE d, STRING unit), EXTRACT(unit FROM DATE d)
Returns one of the numeric date fields from a DATE value. The 'unit'
string can be one of YEAR, QUARTER, MONTH, DAY. This argument value is
case-insensitive.

The implementation mirrors that Impala's EXTRACT(TIMESTAMP ts,
STRING unit). Hive and Oracle SQL have a similar function too.
Reference:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions050.htm
.

DATE_PART(STRING unit, DATE date)
Similar to EXTRACT(), with the argument order reversed. Supports the
same date units as EXTRACT().

The implementation mirrors Impala's DATE_PART(STRING unit,
TIMESTAMP ts) function.

Change-Id: I843358a45eb5faa2c134994600546fc1d0a797c8
Reviewed-on: http://gerrit.cloudera.org:8080/13363
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


> Implement DATE builtin functions
> --------------------------------
>
>                 Key: IMPALA-7369
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7369
>             Project: IMPALA
>          Issue Type: Sub-task
>            Reporter: Attila Jeges
>            Assignee: Attila Jeges
>            Priority: Major
>
> - Built-in functions supported in Hive should be implemented in Impala es well.
> - Already implemented TIMESTAMP built-in functions that work on the date part of timestamps should be implemented for DATE types too.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org