Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-5529

Add additional function signatures for TRUNC()

    Details

    • Epic Color:
      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:

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

        Attachments

          Activity

            People

            • Assignee:
              jinchul Jinchul Kim
              Reporter:
              grahn Greg Rahn
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: