[ 
https://issues.apache.org/jira/browse/HIVE-12028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14956499#comment-14956499
 ] 

Furcy Pin commented on HIVE-12028:
----------------------------------

Exactly, it's the same as "cast(null as int)".
Only shorter and probably not ISO-compliant.


> An empty array is of type Array<String> and incompatible with other array 
> types
> -------------------------------------------------------------------------------
>
>                 Key: HIVE-12028
>                 URL: https://issues.apache.org/jira/browse/HIVE-12028
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 1.1.0, 1.2.1
>            Reporter: Furcy Pin
>
> 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 ;
> ```



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to