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

Liang-Chi Hsieh commented on SPARK-23224:
-----------------------------------------

[https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Union#LanguageManualUnion-ApplyingSubclauses]

The rule is similar as Hive. You can place the clause inside one pair of 
parentheses that enclose the SELECT.
{code:java}

insert overwrite table tmp_wjmdb.tmp_cyk_test1
(select * from tmp_wjmdb.abctest limit 10)
union all
(select * from tmp_wjmdb.abctest limit 20);{code}

> union all will throw gramma exception
> -------------------------------------
>
>                 Key: SPARK-23224
>                 URL: https://issues.apache.org/jira/browse/SPARK-23224
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.2.0
>            Reporter: chenyukang
>            Priority: Major
>
> when keyword "limit " in first sub query , this query will fail with gramma 
> exception
> {code:java}
> spark-sql>
>          >
>          > insert overwrite table tmp_wjmdb.tmp_cyk_test1
>          > select * from tmp_wjmdb.abctest limit 10
>          > union all
>          > select * from tmp_wjmdb.abctest limit 20;
> 18/01/26 12:18:58 INFO SparkSqlParser: Parsing command: insert overwrite 
> table tmp_wjmdb.tmp_cyk_test1
> select * from tmp_wjmdb.abctest limit 10
> union all
> select * from tmp_wjmdb.abctest limit 20
> Error in query:
> mismatched input 'union' expecting {<EOF>, '.', '[', 'OR', 'AND', 'IN', NOT, 
> 'BETWEEN', 'LIKE', RLIKE, 'IS', EQ, '<=>', '<>', '!=', '<', LTE, '>', GTE, 
> '+', '-', '*', '/', '%', 'DIV', '&', '|', '^'}(line 3, pos 0)
> == SQL ==
> insert overwrite table tmp_wjmdb.tmp_cyk_test1
> select * from tmp_wjmdb.abctest limit 10
> union all
> ^^^
> select * from tmp_wjmdb.abctest limit 20
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to