You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by jiangxb1987 <gi...@git.apache.org> on 2017/03/01 16:58:04 UTC

[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

GitHub user jiangxb1987 opened a pull request:

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

    [SPARK-19211][SQL] Explicitly prevent Insert into View or Create View As Insert

    ## What changes were proposed in this pull request?
    
    Currently we don't explicitly forbid the following behaviors:
    1. The statement CREATE VIEW AS INSERT INTO throws the following exception:
    ```
    scala> spark.sql("CREATE VIEW testView AS INSERT INTO tab VALUES (1, \"a\")")
    org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: org.apache.hadoop.hive.ql.metadata.HiveException: at least one column must be specified for the table;
     scala> spark.sql("CREATE VIEW testView(a, b) AS INSERT INTO tab VALUES (1, \"a\")")
    org.apache.spark.sql.AnalysisException: The number of columns produced by the SELECT clause (num: `0`) does not match the number of column names specified by CREATE VIEW (num: `2`).;
    ```
    
    2. The statement INSERT INTO view VALUES throws the following exception from checkAnalysis:
    ```
    scala> spark.sql("INSERT INTO testView VALUES (1, \"a\")")
    org.apache.spark.sql.AnalysisException: Inserting into an RDD-based table is not allowed.;;
    'InsertIntoTable View (`default`.`testView`, [a#16,b#17]), false, false
    +- LocalRelation [col1#14, col2#15]
    ```
    
    After this PR, the behavior changes to:
    ```
    scala> spark.sql("CREATE VIEW testView AS INSERT INTO tab VALUES (1, \"a\")")
    org.apache.spark.sql.AnalysisException: Creating a view as insert into a table is not allowed;
    
    scala> spark.sql("CREATE VIEW testView(a, b) AS INSERT INTO tab VALUES (1, \"a\")")
    org.apache.spark.sql.AnalysisException: Creating a view as insert into a table is not allowed;
    
    scala> spark.sql("INSERT INTO testView VALUES (1, \"a\")")
    org.apache.spark.sql.AnalysisException: `default`.`testView` is a view, inserting into a view is not allowed;
    ```
    
    ## How was this patch tested?
    
    Add a new test case in `SQLViewSuite`;
    Update the corresponding test case in `SQLViewSuite`.

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

    $ git pull https://github.com/jiangxb1987/spark insert-with-view

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

    https://github.com/apache/spark/pull/17125.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 #17125
    
----
commit d1484f9a207f258fc4e9d6f7527cc3b6aa4b9500
Author: jiangxingbo <ji...@gmail.com>
Date:   2017-03-01T15:51:11Z

    explictly prevent insert into view or create view as insert into table.

commit ae28e4bb66ce76f463975d1041b260e53c792b7b
Author: jiangxingbo <ji...@gmail.com>
Date:   2017-03-01T16:55:25Z

    update error message.

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104280528
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,7 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        i.copy(table = resolveRelation(EliminateSubqueryAliases(lookupTableFromCatalog(u))))
    --- End diff --
    
    When we try to insert into a view, the logical plan that `lookupTableFromCatalog()` returns is not expanded, so we have to perform `resolveRelation()` over the node.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104211285
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -1329,6 +1329,16 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
         if (ctx.identifierList != null) {
           operationNotAllowed("CREATE VIEW ... PARTITIONED ON", ctx)
         } else {
    +      // CREATE VIEW ... AS INSERT INTO is not allowed.
    +      val query = ctx.query.queryNoWith
    +      query match {
    --- End diff --
    
    Nit: `ctx.query.queryNoWith match {`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103891636
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    --- End diff --
    
    Hmmm... fixing this in grammar itself would a little bit of work (we also support multi-insert and that makes this harder). I suppose we could try to add a check in the `AstBuilder`.
    
    Why not check this in the `CreateViewCommand`? That seems safer to me.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103863856
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    --- End diff --
    
    ```
    queryNoWith
        : insertInto? queryTerm queryOrganization                                              #singleInsertQuery
        | fromClause multiInsertQueryBody+                                                     #multiInsertQuery
        ;
    ```
    Seems we have mixed them together.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104157426
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,13 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        if (newTable.isInstanceOf[View]) {
    --- End diff --
    
    Just move it to preprocess insert.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104329721
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,7 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        i.copy(table = resolveRelation(EliminateSubqueryAliases(lookupTableFromCatalog(u))))
    --- End diff --
    
    why do we need to resolve the child of view? Once we see the pattern `Insert(View, ...)` we will throw exception, we don't care about whether the child of view is resolved or not.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103858978
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    --- End diff --
    
    `_: InsertIntoHadoopFsRelationCommand`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103892046
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    --- End diff --
    
    This pattern match does not work with multi-inserts (hive feature). Those are represented using a `Union` of inserts.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104280410
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -1329,6 +1329,15 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
         if (ctx.identifierList != null) {
           operationNotAllowed("CREATE VIEW ... PARTITIONED ON", ctx)
         } else {
    +      // CREATE VIEW ... AS INSERT INTO is not allowed.
    +      ctx.query.queryNoWith match {
    +        case s: SingleInsertQueryContext if s.insertInto != null =>
    --- End diff --
    
    when `s.insertInto` will be null?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103891768
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,14 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        newTable match {
    --- End diff --
    
    NIT In this case if would just write the following:
    ```scala
    if (newTable.isInstanceOf[View]) {
      u.failAnalysis(s"${v.desc.identifier} is a view, inserting into a view is not allowed")
    }
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103859056
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    +        throw new AnalysisException("Creating a view as insert into a table is not allowed")
    --- End diff --
    
    It will be nice to put a view name in the error message. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    LGTM, pending tests


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73981/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73894 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73894/testReport)** for PR 17125 at commit [`68cee40`](https://github.com/apache/spark/commit/68cee40fc7a5378d009e3ddc54e80a5fb23531fc).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73958 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73958/testReport)** for PR 17125 at commit [`9af2d7e`](https://github.com/apache/spark/commit/9af2d7e4c249da15711b47936693687db5e0658b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    cc @gatorsmile @cloud-fan Please have a look at this when you have time, thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103858555
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,14 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        newTable match {
    +          case v: View =>
    +            u.failAnalysis(s"${v.desc.identifier} is a view, inserting into a view is not allowed")
    --- End diff --
    
    Can we move this to `PreprocessTableInsertion`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73978/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73857 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73857/testReport)** for PR 17125 at commit [`57b64ad`](https://github.com/apache/spark/commit/57b64add6da307b80776bcc9d765cf4bf734c1f9).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103863369
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    --- End diff --
    
    hmmmm, why `INSERT INTO ...` is a query?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104345227
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,13 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        if (newTable.isInstanceOf[View]) {
    +          u.failAnalysis(s"${newTable.asInstanceOf[View].desc.identifier} is a view, inserting " +
    +            s"into a view is not allowed")
    --- End diff --
    
    Nit: `s"into a view is not allowed"` -> `"into a view is not allowed"`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73981 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73981/testReport)** for PR 17125 at commit [`8d4be05`](https://github.com/apache/spark/commit/8d4be059b458330150ca31e07e2e76a82e5159a4).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104281300
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -1329,6 +1329,15 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
         if (ctx.identifierList != null) {
           operationNotAllowed("CREATE VIEW ... PARTITIONED ON", ctx)
         } else {
    +      // CREATE VIEW ... AS INSERT INTO is not allowed.
    +      ctx.query.queryNoWith match {
    +        case s: SingleInsertQueryContext if s.insertInto != null =>
    --- End diff --
    
    hmm, a select query is `SingleInsertQueryContext`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73780 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73780/testReport)** for PR 17125 at commit [`792cca9`](https://github.com/apache/spark/commit/792cca92883689462f97c9d80f69edb7ea3fa397).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104210669
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala ---
    @@ -484,6 +485,23 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
         }
       }
     
    +  test("create view as insert into table") {
    --- End diff --
    
    Move it to `SparkSqlParserSuite`? 
    
    If we do it here, it will be tested twice. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73857/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104338208
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,13 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        if (newTable.isInstanceOf[View]) {
    --- End diff --
    
    Discussed with @cloud-fan and the concern is that in case the child of the view node is invalid(e.g. exists cyclic view reference or exceed max reference depth), we should still indicate that INSERT INTO VIEW is not allowed(instead of other error messages), so we should not resolve the child of the view, instead we throw an Exception here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104284763
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -1329,6 +1329,15 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
         if (ctx.identifierList != null) {
           operationNotAllowed("CREATE VIEW ... PARTITIONED ON", ctx)
         } else {
    +      // CREATE VIEW ... AS INSERT INTO is not allowed.
    +      ctx.query.queryNoWith match {
    +        case s: SingleInsertQueryContext if s.insertInto != null =>
    --- End diff --
    
    Yeah... You can see that in:
    ```
    queryNoWith
        : insertInto? queryTerm queryOrganization                                              #singleInsertQuery
        | fromClause multiInsertQueryBody+                                                     #multiInsertQuery
        ;
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104121538
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,13 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        if (newTable.isInstanceOf[View]) {
    --- End diff --
    
    In fact I'm neutral with which rule this code block should be placed, but I feel this is not a typical "Preprocess" since the query failed and the process ends.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103978808
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,13 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        if (newTable.isInstanceOf[View]) {
    --- End diff --
    
    The rule `ResolveRelations` executes before `PreprocessTableInsertion`, so we can fail early here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103984820
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,13 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        if (newTable.isInstanceOf[View]) {
    --- End diff --
    
    We prefer to doing all the error handling in the same rule. It can help us find the hole and maintain the codes. cc @cloud-fan 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103858997
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    +        throw new AnalysisException("Creating a view as insert into a table is not allowed")
    +      case i: InsertIntoDataSourceCommand =>
    --- End diff --
    
    The same here


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73981 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73981/testReport)** for PR 17125 at commit [`8d4be05`](https://github.com/apache/spark/commit/8d4be059b458330150ca31e07e2e76a82e5159a4).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104210054
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala ---
    @@ -484,6 +485,23 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
         }
       }
     
    +  test("create view as insert into table") {
    +    withView("testView") {
    +      // Single insert query
    +      val e1 = intercept[ParseException] {
    +        sql(s"CREATE VIEW testView AS INSERT INTO jt VALUES(1, 1)")
    +      }.getMessage
    +      assert(e1.contains("Operation not allowed: CREATE VIEW ... AS INSERT INTO"))
    +
    +      // Multi insert query
    +      val e2 = intercept[ParseException] {
    +        sql(s"CREATE VIEW testView AS FROM jt INSERT INTO tbl1 SELECT * WHERE jt.id < 5 " +
    +          s"INSERT INTO tbl2 SELECT * WHERE jt.id > 4")
    --- End diff --
    
    Nit: remove the above two string interpolators


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104281325
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,7 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        i.copy(table = resolveRelation(EliminateSubqueryAliases(lookupTableFromCatalog(u))))
    --- End diff --
    
    so we will resolve something to `View` by doing this?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73958 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73958/testReport)** for PR 17125 at commit [`9af2d7e`](https://github.com/apache/spark/commit/9af2d7e4c249da15711b47936693687db5e0658b).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73780/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73696 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73696/testReport)** for PR 17125 at commit [`ae28e4b`](https://github.com/apache/spark/commit/ae28e4bb66ce76f463975d1041b260e53c792b7b).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103860516
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    --- End diff --
    
    The sql parser only allows `CREATE VIEW AS query` here, a query can only be a `SELECT ...` or `INSERT INTO ...` or a CTE, so perhaps we don't have to consider other commands here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    LGTM too. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104210022
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala ---
    @@ -484,6 +485,23 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
         }
       }
     
    +  test("create view as insert into table") {
    +    withView("testView") {
    +      // Single insert query
    +      val e1 = intercept[ParseException] {
    +        sql(s"CREATE VIEW testView AS INSERT INTO jt VALUES(1, 1)")
    --- End diff --
    
    Nit: remove string interpolator.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73978 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73978/testReport)** for PR 17125 at commit [`8d4be05`](https://github.com/apache/spark/commit/8d4be059b458330150ca31e07e2e76a82e5159a4).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104280480
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -1329,6 +1329,15 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
         if (ctx.identifierList != null) {
           operationNotAllowed("CREATE VIEW ... PARTITIONED ON", ctx)
         } else {
    +      // CREATE VIEW ... AS INSERT INTO is not allowed.
    +      ctx.query.queryNoWith match {
    +        case s: SingleInsertQueryContext if s.insertInto != null =>
    --- End diff --
    
    For example, `CREATE VIEW v AS SELECT * FROM jt`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104345660
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,13 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        val newTable = EliminateSubqueryAliases(lookupTableFromCatalog(u))
    +        // Inserting into a view is not allowed, we should throw an AnalysisException.
    +        if (newTable.isInstanceOf[View]) {
    +          u.failAnalysis(s"${newTable.asInstanceOf[View].desc.identifier} is a view, inserting " +
    +            s"into a view is not allowed")
    +        }
    +        i.copy(table = newTable)
    --- End diff --
    
    How about?
    
    ```Scala
            lookupTableFromCatalog(u).canonicalized match {
              case v: View =>
                u.failAnalysis(s"Inserting into a view is not allowed. View: ${v.desc.identifier}.")
              case other => i.copy(table = other)
            }
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73894 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73894/testReport)** for PR 17125 at commit [`68cee40`](https://github.com/apache/spark/commit/68cee40fc7a5378d009e3ddc54e80a5fb23531fc).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104280434
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,7 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        i.copy(table = resolveRelation(EliminateSubqueryAliases(lookupTableFromCatalog(u))))
    --- End diff --
    
    why this change?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73894/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73696/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73780 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73780/testReport)** for PR 17125 at commit [`792cca9`](https://github.com/apache/spark/commit/792cca92883689462f97c9d80f69edb7ea3fa397).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73857 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73857/testReport)** for PR 17125 at commit [`57b64ad`](https://github.com/apache/spark/commit/57b64add6da307b80776bcc9d765cf4bf734c1f9).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    **[Test build #73696 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/73696/testReport)** for PR 17125 at commit [`ae28e4b`](https://github.com/apache/spark/commit/ae28e4bb66ce76f463975d1041b260e53c792b7b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    retest this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104211301
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -1329,6 +1329,16 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
         if (ctx.identifierList != null) {
           operationNotAllowed("CREATE VIEW ... PARTITIONED ON", ctx)
         } else {
    +      // CREATE VIEW ... AS INSERT INTO is not allowed.
    +      val query = ctx.query.queryNoWith
    +      query match {
    +        case s: SingleInsertQueryContext if s.insertInto != null =>
    +          operationNotAllowed("CREATE VIEW ... AS INSERT INTO", ctx)
    +        case m: MultiInsertQueryContext =>
    --- End diff --
    
    Nit: `case MultiInsertQueryContext =>`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103865408
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    --- End diff --
    
    can we fix it at parser side? cc @hvanhovell 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Thanks! Merging to master.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    LGTM except 2 questions


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by jiangxb1987 <gi...@git.apache.org>.
Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r104284787
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -604,7 +604,7 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    -        i.copy(table = EliminateSubqueryAliases(lookupTableFromCatalog(u)))
    +        i.copy(table = resolveRelation(EliminateSubqueryAliases(lookupTableFromCatalog(u))))
    --- End diff --
    
    We will resolve the child of the view by doing this I think.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17125: [SPARK-19211][SQL] Explicitly prevent Insert into View o...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17125
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/73958/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17125: [SPARK-19211][SQL] Explicitly prevent Insert into...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17125#discussion_r103860095
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -128,6 +129,15 @@ case class CreateViewCommand(
         qe.assertAnalyzed()
         val analyzedPlan = qe.analyzed
     
    +    // CREATE VIEW AS INSERT INTO ... is not allowed, we should throw an AnalysisException.
    +    analyzedPlan match {
    +      case i: InsertIntoHadoopFsRelationCommand =>
    --- End diff --
    
    shall we forbid all commands? e.g. `CREATE VIEW xxx AS CREATE TABLE ...` should also be disallowed right?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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