Details
-
New Feature
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 2.9.0
-
ghx-label-5
Description
As of Impala 2.9 the current definition of the TRUNC() function is
+-------------+--------------------------+-------------+---------------+ | return type | signature | binary type | is persistent | +-------------+--------------------------+-------------+---------------+ | TIMESTAMP | trunc(TIMESTAMP, STRING) | BUILTIN | true | +-------------+--------------------------+-------------+---------------+
The additional signatures to be added are:
result | function | arguments ------------------+----------+------------------------- DOUBLE PRECISION | TRUNC | (DOUBLE PRECISION) NUMERIC | TRUNC | (NUMERIC(ANY)) NUMERIC | TRUNC | (NUMERIC(ANY), INTEGER)
Examples
postgres=# select trunc(cast(42.999 as decimal(5,3))); trunc ------- 42 postgres=# select trunc(cast(42.999 as decimal(5,3)),1); trunc ------- 42.9 postgres=# select trunc(cast(42.999 as double precision)); trunc ------- 42
References:
- https://my.vertica.com/docs/8.1.x/HTML/index.htm#Authoring/SQLReferenceManual/Functions/Mathematical/TRUNC.htm
- https://www.postgresql.org/docs/current/static/functions-math.html
The return precision/scale for a decimal should be the same as the input. For example, trunc(decimal(x,y)) should return decimal(x,y).