impala-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Rahn (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IMPALA-5529) Add additional function signatures for TRUNC()
Date Sun, 18 Jun 2017 00:30:00 GMT
Greg Rahn created IMPALA-5529:
---------------------------------

             Summary: Add additional function signatures for TRUNC()
                 Key: IMPALA-5529
                 URL: https://issues.apache.org/jira/browse/IMPALA-5529
             Project: IMPALA
          Issue Type: New Feature
          Components: Frontend
    Affects Versions: Impala 2.9.0
            Reporter: Greg Rahn


As of Impala 2.9 the current definition of the TRUNC() function is
{noformat}
+-------------+--------------------------+-------------+---------------+
| return type | signature                | binary type | is persistent |
+-------------+--------------------------+-------------+---------------+
| TIMESTAMP   | trunc(TIMESTAMP, STRING) | BUILTIN     | true          |
+-------------+--------------------------+-------------+---------------+
{noformat}

The additional signatures to be added are:
{noformat}
      result      | function |        arguments
------------------+----------+-------------------------
 DOUBLE PRECISION | TRUNC    | (DOUBLE PRECISION)
 NUMERIC          | TRUNC    | (NUMERIC(ANY))
 NUMERIC          | TRUNC    | (NUMERIC(ANY), INTEGER)
{noformat}

Examples
{noformat}
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
{noformat}

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).




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message