You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (Jira)" <ji...@apache.org> on 2019/10/08 05:43:16 UTC

[jira] [Resolved] (SPARK-24430) CREATE VIEW with UNION statement: Failed to recognize predicate 'UNION'.

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

Hyukjin Kwon resolved SPARK-24430.
----------------------------------
    Resolution: Incomplete

> CREATE VIEW with UNION statement: Failed to recognize predicate 'UNION'.
> ------------------------------------------------------------------------
>
>                 Key: SPARK-24430
>                 URL: https://issues.apache.org/jira/browse/SPARK-24430
>             Project: Spark
>          Issue Type: Request
>          Components: Spark Core, SQL
>    Affects Versions: 2.2.1
>            Reporter: Volodymyr Glushak
>            Priority: Major
>              Labels: bulk-closed
>
> When I executes following SQL statement:
> {code:java}
> spark.sql('CREATE VIEW view_12 AS
> SELECT * FROM (
>   SELECT * FROM table1
>   UNION ALL
>   SELECT * FROM table2
> ) UT')
> {code}
>  
> It successfully creates view in HIVE, which I can query via Apache Spark.
> However if I'm trying to query the same view directly via HIVE, I've got an error:
> {code:java}
> org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line 6:6 Failed to recognize predicate 'UNION'.
> Failed rule: 'identifier' in subquery source
> {code}
>  
> *Investigation*
> Under hood, spark generate following SQL statement for this view:
> {code:java}
> CREATE VIEW `view_12` AS
> SELECT *
> FROM (SELECT * FROM
>             (
>                    (SELECT * FROM (SELECT * FROM `db1`.`table1`) AS gen_subquery_0)
>                              UNION ALL
>                     (SELECT * FROM (SELECT  * FROM `db1`.`tabl2`) AS gen_subquery_1)
>             ) AS UT
>           ) AS UT
> {code}
> If I try to execute this statement in HIVE it fails with the same reason.
> The easiest way to fix it, is to remove parentheses from outer queries on lines 5 and 7.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org