You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Xuefu Zhang (JIRA)" <ji...@apache.org> on 2014/12/02 20:02:14 UTC

[jira] [Commented] (HIVE-9008) primary table in union

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

Xuefu Zhang commented on HIVE-9008:
-----------------------------------

This JIRA also needs a better title. The problem described here seems similar to that in HIVE-8009.

> primary table in union
> ----------------------
>
>                 Key: HIVE-9008
>                 URL: https://issues.apache.org/jira/browse/HIVE-9008
>             Project: Hive
>          Issue Type: Sub-task
>            Reporter: Pengcheng Xiong
>
> Following http://dev.mysql.com/doc/refman/5.0/en/union.html
> The column names from the first SELECT statement are used as the column names for the results returned. Selected columns listed in corresponding positions of each SELECT statement should have the same data type. (For example, the first column selected by the first statement should have the same type as the first column selected by the other statements.)
> If the data types of corresponding SELECT columns do not match, the types and lengths of the columns in the UNION result take into account the values retrieved by all of the SELECT statements.
> We can say
> select A.id from A 
> union 
> select B.id from B
> order by id
> We can say
> select A.id as a from A 
> union 
> select B.id from B
> order by a
> We can NOT say
> select A.id as a from A 
> union 
> select B.id from B
> order by A.id
> ERROR 1054 (42S22): Unknown column 'A.id' in 'order clause'
> We can NOT say
> select A.id as a from A 
> union 
> select B.id from B
> order by B.id
> ERROR 1054 (42S22): Unknown column 'B.id' in 'order clause'
> We can say
> select A.id as a from A 
> union 
> (select B.id from B
> order by B.id)



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