[GitHub] spark pull request #15854: [SPARK-18415] [SQL] Weird Plan Output when CTE us...

2016-11-16 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/spark/pull/15854


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15854: [SPARK-18415] [SQL] Weird Plan Output when CTE us...

2016-11-11 Thread gatorsmile
Github user gatorsmile commented on a diff in the pull request:

https://github.com/apache/spark/pull/15854#discussion_r87688482
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
@@ -33,7 +33,9 @@ import org.apache.spark.sql.types.MetadataBuilder
  * ViewType is used to specify the expected view type when we want to 
create or replace a view in
  * [[CreateViewCommand]].
  */
-sealed trait ViewType
+sealed trait ViewType {
+  override def toString: String = getClass.getSimpleName.filter(_ != '$')
--- End diff --

Yeah!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15854: [SPARK-18415] [SQL] Weird Plan Output when CTE us...

2016-11-11 Thread rxin
Github user rxin commented on a diff in the pull request:

https://github.com/apache/spark/pull/15854#discussion_r87687899
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
@@ -33,7 +33,9 @@ import org.apache.spark.sql.types.MetadataBuilder
  * ViewType is used to specify the expected view type when we want to 
create or replace a view in
  * [[CreateViewCommand]].
  */
-sealed trait ViewType
+sealed trait ViewType {
+  override def toString: String = getClass.getSimpleName.filter(_ != '$')
--- End diff --

stripSuffix?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15854: [SPARK-18415] [SQL] Weird Plan Output when CTE us...

2016-11-11 Thread gatorsmile
GitHub user gatorsmile opened a pull request:

https://github.com/apache/spark/pull/15854

[SPARK-18415] [SQL] Weird Plan Output when CTE used in RunnableCommand

### What changes were proposed in this pull request?
Currently, when CTE is used in RunnableCommand, the Analyzer does not 
replace the logical node `With`. The child plan of RunnableCommand is not 
resolved. Thus, the output of the `With` plan node looks very confusing.
For example,
```
sql("CREATE VIEW cte_view AS WITH w AS (SELECT 1 AS n) SELECT n FROM 
w").explain()
```
The output is like
```
ExecutedCommand
   +- CreateViewCommand `w`, WITH w AS (SELECT 1 AS n) SELECT n FROM w, 
false, false, org.apache.spark.sql.execution.command.PersistedView$@2251b87b
 +- 'With [(w,SubqueryAlias w
   +- Project [1 AS n#16]
  +- OneRowRelation$
   )]
+- 'Project ['n]
   +- 'UnresolvedRelation `w`
```
After the fix, the output is as shown below.
```
ExecutedCommand
   +- CreateViewCommand `cte_view`, WITH w AS (SELECT 1 AS n) SELECT n FROM 
w, false, false, PersistedView
 +- CTE [w]
+- 'Project ['n]
   +- 'UnresolvedRelation `w`
```

### How was this patch tested?
Manual

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/gatorsmile/spark cteName

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/15854.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #15854


commit 1dd5a7f2a4fb41642f0b8500e22384abd7ed1f14
Author: gatorsmile 
Date:   2016-11-11T21:12:27Z

fix plan.

commit 55a4bff3cf504d3a8ad11e91637d1cc67fd9b111
Author: gatorsmile 
Date:   2016-11-11T21:15:25Z

fix plan.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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