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

Igor Ngouagna commented on SPARK-27203:
---------------------------------------

I thought "UNION ALL" was part of the issue here, but no.. if I remove it and 
just select from one table, I still got a compil error:

{code:bash}
Error: Error while compiling statement: FAILED: SemanticException line 1:593 
missing ) at 'NULLS' near 'LAST' in subquery source
line 1:599 missing ) at 'LAST' near 'LAST' in subquery source
line 1:604 missing ) at 'ROWS' near 'LAST' in subquery source in definition of 
VIEW test_cte_view [
SELECT `gen_attr_0` AS `id`, `gen_attr_1` AS `status`, `gen_attr_2` AS `idate` 
FROM (SELECT `gen_attr_0`, `gen_attr_1`, `gen_attr_2` FROM (SELECT 
`gen_attr_0`, `gen_attr_1`, `gen_attr_2` FROM (SELECT `id` AS `gen_attr_0`, 
`status` AS `gen_attr_1`, `idate` AS `gen_attr_2` FROM `db`.`test_cte`) AS 
gen_subquery_0) AS cte INNER JOIN (SELECT `gen_attr_3`, `gen_attr_4`, 
`gen_attr_5` FROM (SELECT `gen_attr_3`, `gen_attr_4`, `gen_attr_5` FROM (SELECT 
gen_subquery_2.`gen_attr_3`, gen_subquery_2.`gen_attr_4`, row_number() OVER 
(PARTITION BY `gen_attr_3` ORDER BY `gen_attr_4` DESC NULLS LAST ROWS BETWEEN 
UNBOUNDED PRECEDING AND CURRENT ROW) AS `gen_attr_5` FROM (SELECT `gen_attr_3`, 
`gen_attr_4` FROM (SELECT `gen_attr_3`, `gen_attr_6`, `gen_attr_4` FROM (SELECT 
`id` AS `gen_attr_3`, `status` AS `gen_attr_6`, `idate` AS `gen_attr_4` FROM 
`db`.`test_cte`) AS gen_subquery_1) AS cte) AS gen_subquery_2) AS 
gen_subquery_3) AS tmp WHERE (`gen_attr_5` = 1)) AS tmp_2 ON ((`gen_attr_0` = 
`gen_attr_3`) AND (`gen_attr_2` = `gen_attr_4`))) AS cte
] used as test_cte_view at Line 1:14 (state=42000,code=40000)
{code}

> Spark Fails to read a view using CTE (WITH clause) and created via beeline 
> ---------------------------------------------------------------------------
>
>                 Key: SPARK-27203
>                 URL: https://issues.apache.org/jira/browse/SPARK-27203
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.1.1
>            Reporter: Igor Ngouagna
>            Priority: Major
>
> Spark fails when trying to read a view which code involve CTE, and which is 
> created via beeline.
> For example, considering the following view, created via Beeline:
> {code:sql}
> create view db.test as 
> with q1 as (select 1 as n)
> select n from q1
> {code}
> When you do
> {code:java}
> spark.sql("select * from db.test").show()
> {code}
> The output is like
> {code}
> 'Table or view not found: q1; line 2 pos 14'
> Traceback (most recent call last):
>   File 
> "/DATA/fs11/hadoop/yarn/local/usercache/ingouagn/appcache/application_1552973526615_3878/container_e380_1552973526615_3878_01_000001/pyspark.zip/pyspark/sql/session.py",
>  line 545, in sql
>     return DataFrame(self._jsparkSession.sql(sqlQuery), self._wrapped)
>   File 
> "/DATA/fs11/hadoop/yarn/local/usercache/ingouagn/appcache/application_1552973526615_3878/container_e380_1552973526615_3878_01_000001/py4j-0.10.4-src.zip/py4j/java_gateway.py",
>  line 1133, in __call__
>     answer, self.gateway_client, self.target_id, self.name)
>   File 
> "/DATA/fs11/hadoop/yarn/local/usercache/ingouagn/appcache/application_1552973526615_3878/container_e380_1552973526615_3878_01_000001/pyspark.zip/pyspark/sql/utils.py",
>  line 69, in deco
>     raise AnalysisException(s.split(': ', 1)[1], stackTrace)
> pyspark.sql.utils.AnalysisException: 'Table or view not found: q1; line 2 pos 
> 14'
> {code}
>  
> *Spark: 2.1.1*
> *Beeline: 1.2.1000*
>  



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

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

Reply via email to