You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Bill Wailliam (JIRA)" <ji...@apache.org> on 2016/03/03 12:55:18 UTC

[jira] [Updated] (HIVE-6189) Support top level union all statements

     [ https://issues.apache.org/jira/browse/HIVE-6189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bill Wailliam updated HIVE-6189:
--------------------------------
    Description: 
I've always wondered why union all has to be in subqueries in hive.

After looking at it, problems are:

- Hive Parser:
  - Union happens at the wrong place (insert ... select ... union all select ...) is parsed as (insert select) union select.
  - There are many rewrite rules in the parser to force any query into the a from - insert -select form. No doubt for historical reasons.
- Plan generation/semantic analysis assumes top level "TOK_QUERY" and not top level "TOK_UNION".

The rewrite rules don't work when we move the "UNION ALL" into the select statements. However, it's not hard to do that in code.

  was:
I've always wondered why union all has to be in subqueries in hive.

After looking at it, problems are:

- Hive Parser:
  - Union happens at the wrong place (insert ... select ... union all select ...) is parsed as (insert select) union select.
  - There are many rewrite rules in the parser to force any query into the a from - insert -select form. No doubt for historical reasons.
- Plan generation/semantic analysis assumes top level "TOK_QUERY" and not top level "TOK_UNION".

The rewrite rules don't work when we move the "UNION ALL" recursion into the select statements. However, it's not hard to do that in code.


> Support top level union all statements
> --------------------------------------
>
>                 Key: HIVE-6189
>                 URL: https://issues.apache.org/jira/browse/HIVE-6189
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Gunther Hagleitner
>            Assignee: Gunther Hagleitner
>             Fix For: 0.13.0
>
>         Attachments: HIVE-6189.1.patch, HIVE-6189.2.patch, HIVE-6189.3.patch
>
>
> I've always wondered why union all has to be in subqueries in hive.
> After looking at it, problems are:
> - Hive Parser:
>   - Union happens at the wrong place (insert ... select ... union all select ...) is parsed as (insert select) union select.
>   - There are many rewrite rules in the parser to force any query into the a from - insert -select form. No doubt for historical reasons.
> - Plan generation/semantic analysis assumes top level "TOK_QUERY" and not top level "TOK_UNION".
> The rewrite rules don't work when we move the "UNION ALL" into the select statements. However, it's not hard to do that in code.



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