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

ABS(int) should return an INT instead of DOUBLE

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Impala 2.1
    • Impala 2.1
    • None
    • None

    Description

      It's unlikely that people would want their INT data to turn into a DOUBLE as part of ABS(). Other systems such as Postgresql retain the INT.

      Query: create TABLE FOO AS SELECT ABS(CAST(1 AS INT)) col
      +-------------------+
      | summary           |
      +-------------------+
      | Inserted 1 row(s) |
      +-------------------+
      Fetched 1 row(s) in 0.33s
      
      
      [casey-desktop:21000] > desc foo;
      Query: describe foo
      +------+--------+---------+
      | name | type   | comment |
      +------+--------+---------+
      | col  | double |         |
      +------+--------+---------+
      Fetched 1 row(s) in 0.00s
      
      functional=# CREATE TABLE FOO AS SELECT ABS(CAST(1 AS INT)) col;
      SELECT 1
      
      
      functional=# \d foo;
            Table "public.foo"
       Column |  Type   | Modifiers 
      --------+---------+-----------
       col    | integer | 
      

      Example usage

      Query: select now() + interval abs(int_col) year from alltypestiny
      ERROR: AnalysisException: Operand 'abs(int_col)' of timestamp arithmetic expression 'now() + INTERVAL abs(int_col) year' returns type 'DOUBLE'. Expected an integer type.
      

      Attachments

        Activity

          People

            mgrund_impala_bb91 Martin Grund
            caseyc casey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: