Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-12028

An empty array is of type Array<String> and incompatible with other array types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.1.0, 1.2.1
    • None
    • None
    • None

    Description

      How to reproduce:

      ```sql
      SELECT ARRAY(ARRAY(1),ARRAY()) ;
      FAILED: SemanticException [Error 10016]: Line 1:22 Argument type mismatch 'ARRAY': Argument type "array<string>" is different from preceding arguments. Previous type was "array<int>"

      SELECT COALESCE(ARRAY(1),ARRAY()) ;
      FAILED: SemanticException [Error 10016]: Line 1:25 Argument type mismatch 'ARRAY': The expressions after COALESCE should all have the same type: "array<int>" is expected but "array<string>" is found
      ```

      This is especially painful for COALESCE, as we cannot
      remove NULLS after doing a JOIN.

      The same problem holds with maps.

      The only workaround I could think of (except adding my own UDF)
      is quite ugly :

      ```sql
      SELECT ARRAY(ARRAY(1),empty.arr) FROM (SELECT collect_set(id) as arr FROM (SELECT 1 as id) T WHERE id=0) empty ;
      ```

      Attachments

        Activity

          People

            Unassigned Unassigned
            fpin Furcy Pin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: