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:00:13 UTC

[jira] [Commented] (HIVE-9009) order by

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

Xuefu Zhang commented on HIVE-9009:
-----------------------------------

I believe this JIRA deserves a better title. The problem described does not seem to be a problem, contraversial at least. To have an order by, you need a select, not a union. To achieve what you want, you need to rewrite your query as:

{code}
select * from (select id from A union all select id from B) C order by C.id;
{code}

> order by
> --------
>
>                 Key: HIVE-9009
>                 URL: https://issues.apache.org/jira/browse/HIVE-9009
>             Project: Hive
>          Issue Type: Sub-task
>            Reporter: Pengcheng Xiong
>
> Currently Hive will treat
> select id from A 
> union all
> select id from B
> order by id
> as
> select id from A 
> union all
> (select id from B
> order by id)
> However, it should be treated as
> (select id from A 
> union all
> select id from B)
> order by id



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