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

Dongjoon Hyun edited comment on SPARK-17982 at 10/19/16 12:55 AM:
------------------------------------------------------------------

Sorry, [~tafra...@gmail.com]. Now, I understand what you meant by `limit`.
The following is the simplified version of your case, isn't it?
{code}
scala> spark.version
res0: String = 2.1.0-SNAPSHOT

scala> sql("CREATE TABLE tbl(id INT)")
res1: org.apache.spark.sql.DataFrame = []

scala> sql("CREATE VIEW v1(id2) AS SELECT id FROM tbl")
res2: org.apache.spark.sql.DataFrame = []

scala> sql("CREATE VIEW v2 AS SELECT id FROM tbl limit 2")
res3: org.apache.spark.sql.DataFrame = []

scala> sql("CREATE VIEW v3(id2) AS SELECT id FROM tbl limit 2")
java.lang.RuntimeException: Failed to analyze the canonicalized SQL: ...
{code}


was (Author: dongjoon):
Sorry, [~tafra...@gmail.com]. Now, I understand what you meant by `limit`.
The following is the simplified version of your case, isn't it?
{code}
scala> spark.version
res0: String = 2.1.0-SNAPSHOT

scala> sql("CREATE TABLE tbl(id INT)")
res1: org.apache.spark.sql.DataFrame = []

scala> sql("CREATE VIEW v1(id2) AS SELECT id FROM tbl")
res2: org.apache.spark.sql.DataFrame = []

scala> sql("CREATE VIEW v2 AS SELECT id FROM tbl limit 2")
res3: org.apache.spark.sql.DataFrame = []

scala> sql("CREATE VIEW v2(id2) AS SELECT id FROM tbl limit 2")
java.lang.RuntimeException: Failed to analyze the canonicalized SQL: ...
{code}

> Spark 2.0.0  CREATE VIEW statement fails :: java.lang.RuntimeException: 
> Failed to analyze the canonicalized SQL. It is possible there is a bug in 
> Spark.
> --------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-17982
>                 URL: https://issues.apache.org/jira/browse/SPARK-17982
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.0.0, 2.0.1
>         Environment: spark 2.0.0
>            Reporter: Franck Tago
>
> The following statement fails in the spark shell . 
> scala> spark.sql("CREATE VIEW 
> DEFAULT.sparkshell_2_VIEW__hive_quoted_with_where (WHERE_ID , WHERE_NAME ) AS 
> SELECT `where`.id,`where`.name FROM DEFAULT.`where` limit 2")
> scala> spark.sql("CREATE VIEW 
> DEFAULT.sparkshell_2_VIEW__hive_quoted_with_where (WHERE_ID , WHERE_NAME ) AS 
> SELECT `where`.id,`where`.name FROM DEFAULT.`where` limit 2")
> java.lang.RuntimeException: Failed to analyze the canonicalized SQL: SELECT 
> `gen_attr_0` AS `WHERE_ID`, `gen_attr_2` AS `WHERE_NAME` FROM (SELECT 
> `gen_attr_1` AS `gen_attr_0`, `gen_attr_3` AS `gen_attr_2` FROM SELECT 
> `gen_attr_1`, `gen_attr_3` FROM (SELECT `id` AS `gen_attr_1`, `name` AS 
> `gen_attr_3` FROM `default`.`where`) AS gen_subquery_0 LIMIT 2) AS 
> gen_subquery_1
>   at 
> org.apache.spark.sql.execution.command.CreateViewCommand.prepareTable(views.scala:192)
>   at 
> org.apache.spark.sql.execution.command.CreateViewCommand.run(views.scala:122)
>   at 
> org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:60)
>   at 
> org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:58)
>   at 
> org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:74)
>   at 
> org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
>   at 
> org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
>   at 
> org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:136)
>   at 
> org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
>   at 
> org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:133)
>   at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:114)
>   at 
> org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:86)
>   at 
> org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:86)
>   at org.apache.spark.sql.Dataset.<init>(Dataset.scala:186)
>   at org.apache.spark.sql.Dataset.<init>(Dataset.scala:167)
>   at org.apache.spark.sql.Dataset$.ofRows(Dataset.scala:65)
> This appears to be a limitation of the create view statement .



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

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

Reply via email to