diff --git a/docs/impala_keydefs.ditamap b/docs/impala_keydefs.ditamap index 56de93764..02cff8aaf 100644 --- a/docs/impala_keydefs.ditamap +++ b/docs/impala_keydefs.ditamap @@ -10516,6 +10516,7 @@ under the License. + Impala 2.11 Impala 2.10 Impala 2.9 Impala 2.8 @@ -10531,6 +10532,9 @@ under the License. Impala 1.3 + + Impala 2.11.0 Impala 2.10.0 Impala 2.9.0 Impala 2.8.0 diff --git a/docs/shared/impala_common.xml b/docs/shared/impala_common.xml index c27289386..dc8cdb521 100644 --- a/docs/shared/impala_common.xml +++ b/docs/shared/impala_common.xml @@ -2787,7 +2787,10 @@ flight_num: INT32 SNAPPY DO:83456393 FPO:83488603 SZ:10216514/11474301 each value.

-

+

+ Added in: +

+

Added in:

diff --git a/docs/topics/impala_datetime_functions.xml b/docs/topics/impala_datetime_functions.xml index de8291b0d..f4d062ae4 100644 --- a/docs/topics/impala_datetime_functions.xml +++ b/docs/topics/impala_datetime_functions.xml @@ -389,6 +389,102 @@ select date_sub(cast('2016-05-31' as timestamp), interval 1 months) as 'april_31 + + +

+ date_trunc(string unit, timestamp) +
+ +
+ date_trunc() function + Purpose: Truncates a TIMESTAMP value to the specified precision. +

+ Unit argument: The unit argument value for truncating + TIMESTAMP values is not case-sensitive. This argument string + can be one of: +

+ +

+ For example, calling date_trunc('hour',ts) truncates + ts to the beginning of the corresponding hour, with + all minutes, seconds, milliseconds, and so on set to zero. Calling + date_trunc('milliseconds',ts) truncates + ts to the beginning of the corresponding millisecond, + with all microseconds and nanoseconds set to zero. +

+ + The sub-second units are specified in plural form. All units representing + one second or more are specified in singular form. + +

+

+

+ Although this function is similar to calling TRUNC() + with a TIMESTAMP argument, the order of arguments + and the recognized units are different between TRUNC() + and DATE_TRUNC(). Therefore, these functions are not + interchangeable. +

+

+ This function is typically used in GROUP BY + queries to aggregate results from the same hour, day, week, month, quarter, and so on. + You can also use this function in an INSERT ... SELECT into a + partitioned table to divide TIMESTAMP values into the correct partition. +

+

+ Because the return value is a TIMESTAMP, if you cast the result of + DATE_TRUNC() to STRING, you will often see zeroed-out portions such as + 00:00:00 in the time field. If you only need the individual units such as hour, day, + month, or year, use the EXTRACT() function instead. If you need the individual units + from a truncated TIMESTAMP value, run the TRUNCATE() function on the + original value, then run EXTRACT() on the result. +

+

+ Return type: timestamp +

+

+

+ The following examples show how to call DATE_TRUNC() with different unit values: +

+ +select now(), date_trunc('second', now()); ++-------------------------------+-----------------------------------+ +| now() | date_trunc('second', now()) | ++-------------------------------+-----------------------------------+ +| 2017-12-05 13:58:04.565403000 | 2017-12-05 13:58:04 | ++-------------------------------+-----------------------------------+ + +select now(), date_trunc('hour', now()); ++-------------------------------+---------------------------+ +| now() | date_trunc('hour', now()) | ++-------------------------------+---------------------------+ +| 2017-12-05 13:59:01.884459000 | 2017-12-05 13:00:00 | ++-------------------------------+---------------------------+ + +select now(), date_trunc('millennium', now()); ++-------------------------------+---------------------------------+ +| now() | date_trunc('millennium', now()) | ++-------------------------------+---------------------------------+ +| 2017-12-05 14:00:30.296812000 | 2000-01-01 00:00:00 | ++-------------------------------+---------------------------------+ + +
+ + +