Hive
  1. Hive
  2. HIVE-1490

More implicit type conversion: UNION ALL and COALESCE

    Details

      Description

      This is a usecase that frequently annoys me:

      SELECT TRANSFORM(stuff)
      USING 'script'
      AS thing1, thing2
      FROM some_table

      UNION ALL

      SELECT a.thing1, a.thing2
      FROM some_other_table a

      ...this fails when a.thing1 and a.thing2 are anything but STRING, because all output of TRANSFORM is STRING.

      In this case, a.thing1 and a.thing2 should be implicitly converted to string.

      COALESCE(a.thing1, a.thing2, a.thing3) should similarly do implicit type conversion among the arguments. If two are INT and one is BIGINT, upgrade the INTs, etc.

      At the very least, it would be nice to have syntax like

      SELECT TRANSFORM(stuff)
      USING 'script'
      AS thing1 INT, thing2 INT

      ...which would effectively cast the output column to the specified type. But really, type conversion should work.

        Issue Links

          Activity

          Adam Kramer created issue -
          Hide
          Adam Kramer added a comment -

          Based on http://wiki.apache.org/hadoop/Hive/HiveQL/Types#Implicit_and_Explicit_Type_Conversions this appears to actually be a bug rather than an improvement.

          Show
          Adam Kramer added a comment - Based on http://wiki.apache.org/hadoop/Hive/HiveQL/Types#Implicit_and_Explicit_Type_Conversions this appears to actually be a bug rather than an improvement.
          Adam Kramer made changes -
          Field Original Value New Value
          Issue Type Improvement [ 4 ] Bug [ 1 ]
          Hide
          Adam Kramer added a comment -

          Also present in CASE statements:

          FAILED: Error in semantic analysis: line 37:57 Argument Type Mismatch '$.foo': The expressions after THEN should have the same type: "int" is expected but "string" is found

          Show
          Adam Kramer added a comment - Also present in CASE statements: FAILED: Error in semantic analysis: line 37:57 Argument Type Mismatch '$.foo': The expressions after THEN should have the same type: "int" is expected but "string" is found
          Franklin Hu made changes -
          Link This issue incorporates HIVE-2305 [ HIVE-2305 ]
          Syed S. Albiz made changes -
          Assignee Syed S. Albiz [ salbiz ]
          Hide
          Syed S. Albiz added a comment -

          Fixed as part of JIRA HIVE-872

          Show
          Syed S. Albiz added a comment - Fixed as part of JIRA HIVE-872
          Syed S. Albiz made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Carl Steinbach made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Carl Steinbach made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Duplicate [ 3 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          364d 2h 9m 1 Syed S. Albiz 26/Jul/11 23:44
          Resolved Resolved Reopened Reopened
          1h 10m 1 Carl Steinbach 27/Jul/11 00:54
          Reopened Reopened Resolved Resolved
          11s 1 Carl Steinbach 27/Jul/11 00:54

            People

            • Assignee:
              Syed S. Albiz
              Reporter:
              Adam Kramer
            • Votes:
              3 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development