You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by cloud-fan <gi...@git.apache.org> on 2015/10/06 01:38:55 UTC

[GitHub] spark pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

GitHub user cloud-fan opened a pull request:

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

    [SPARK-10337][SQL] fix hive views on non-hive-compatible tables.

    add a new config to deal with this special case.

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

    $ git pull https://github.com/cloud-fan/spark view-master

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

    https://github.com/apache/spark/pull/8990.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 #8990
    
----
commit c427159f5784cb62fd709b5ec2a3429f37be0fd7
Author: Wenchen Fan <cl...@163.com>
Date:   2015-10-05T21:25:43Z

    fix hive views on non-hive-compatible tables.

----


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146383414
  
      [Test build #43368 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43368/consoleFull) for   PR 8990 at commit [`c7afcd4`](https://github.com/apache/spark/commit/c7afcd4d28aa056253bf6553b27982c14348a2d5).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41415507
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -342,7 +358,8 @@ private[hive] object HiveQl extends Logging {
         }
       }
     
    -  protected def getClauses(clauseNames: Seq[String], nodeList: Seq[ASTNode]): Seq[Option[Node]] = {
    +  protected def getClauses(clauseNames: Seq[String], nodeList: Seq[ASTNode])
    +      : Seq[Option[ASTNode]] = {
    --- End diff --
    
    ```
    protected def getClauses(
        clauseNames: Seq[String],
        nodeList: Seq[ASTNode]): Seq[Option[ASTNode]]
    ```


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146468890
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146291102
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146284281
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146420914
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145700624
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41225405
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala ---
    @@ -1248,4 +1248,12 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
             """.stripMargin), Row("b", 6.0) :: Row("a", 7.0) :: Nil)
         }
       }
    +
    +  test("SPARK-10337: correctly handle hive views") {
    +    withSQLConf("spark.sql.hive.nonNativeView" -> "true") {
    +      sqlContext.range(1, 10).write.format("json").saveAsTable("jt")
    +      sql("CREATE VIEW testView AS SELECT id FROM jt")
    +      checkAnswer(sql("SELECT * FROM testView ORDER BY id"), (1 to 9).map(i => Row(i)))
    +    }
    +  }
    --- End diff --
    
    Do we have view tests (to make sure we are good when this flag is false) in the hive compatibility suite?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146381878
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145975883
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146048553
  
      [Test build #43310 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43310/consoleFull) for   PR 8990 at commit [`c388717`](https://github.com/apache/spark/commit/c388717c93c36dd956d0eef01597c104a542e4c6).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145699557
  
      [Test build #43262 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43262/console) for   PR 8990 at commit [`c427159`](https://github.com/apache/spark/commit/c427159f5784cb62fd709b5ec2a3429f37be0fd7).
     * This patch **fails RAT tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public class BufferHolder `
      * `public class UnsafeArrayWriter `
      * `public class UnsafeRowWriter `
      * `case class LogicalRelation(`
      * `case class CreateViewAsSelect(`



---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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/8990#discussion_r41425875
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala ---
    @@ -1248,4 +1248,47 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
             """.stripMargin), Row("b", 6.0) :: Row("a", 7.0) :: Nil)
         }
       }
    +
    +  test("create hive view for json table") {
    +    // json table is not hive-compatible, make sure the new flag fix it.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("jt") {
    +        sqlContext.range(1, 10).write.format("json").saveAsTable("jt")
    +        sql("CREATE VIEW testView AS SELECT id FROM jt")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id"), (1 to 9).map(i => Row(i)))
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    +
    +  test("create hive view for partitioned parquet table") {
    +    // partitioned parquet table is not hive-compatible, make sure the new flag fix it.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("parTable") {
    +        val df = Seq(1 -> "a").toDF("i", "j")
    +        df.write.format("parquet").partitionBy("i").saveAsTable("parTable")
    +        sql("CREATE VIEW testView AS SELECT i, j FROM parTable")
    +        checkAnswer(sql("SELECT * FROM testView"), Row(1, "a"))
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    +
    +  test("create hive view for joined tables") {
    +    // make sure the new flag can handle some complex cases like join and schema change.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("jt1", "jt2") {
    +        sqlContext.range(1, 10).toDF("id1").write.format("json").saveAsTable("jt1")
    +        sqlContext.range(1, 10).toDF("id2").write.format("json").saveAsTable("jt2")
    +        sql("CREATE VIEW testView AS SELECT * FROM jt1 JOIN jt2 ON id1 == id2")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id1"), (1 to 9).map(i => Row(i, i)))
    +
    +        val df = (1 until 10).map(i => i -> i).toDF("id1", "newCol")
    +        df.write.format("json").mode(SaveMode.Overwrite).saveAsTable("jt1")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id1"), (1 to 9).map(i => Row(i, i)))
    +
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    --- End diff --
    
    we will parse it to table identifier, so having the database part is OK.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146470805
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146047882
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146037100
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43301/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146333741
  
      [Test build #43347 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43347/console) for   PR 8990 at commit [`58fac13`](https://github.com/apache/spark/commit/58fac138eb2da3320bc8abb75eb0141d5de42d7b).
     * This patch **fails MiMa 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146012307
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41225536
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala ---
    @@ -1248,4 +1248,12 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
             """.stripMargin), Row("b", 6.0) :: Row("a", 7.0) :: Nil)
         }
       }
    +
    +  test("SPARK-10337: correctly handle hive views") {
    +    withSQLConf("spark.sql.hive.nonNativeView" -> "true") {
    +      sqlContext.range(1, 10).write.format("json").saveAsTable("jt")
    +      sql("CREATE VIEW testView AS SELECT id FROM jt")
    +      checkAnswer(sql("SELECT * FROM testView ORDER BY id"), (1 to 9).map(i => Row(i)))
    +    }
    +  }
    --- End diff --
    
    Also, do we need to design more cases to test when this flag is true?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146473488
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43391/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146384278
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43368/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146003615
  
      [Test build #43294 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43294/console) for   PR 8990 at commit [`d54ec33`](https://github.com/apache/spark/commit/d54ec3389a5b072639494c041bbf5074a05b48d4).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `case class CreateViewAsSelect(`



---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146663391
  
      [Test build #43405 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43405/console) for   PR 8990 at commit [`d3eed7b`](https://github.com/apache/spark/commit/d3eed7bb684e2f79ab7a7f43b16f482f1b1910ef).
     * 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146384271
  
      [Test build #43368 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43368/console) for   PR 8990 at commit [`c7afcd4`](https://github.com/apache/spark/commit/c7afcd4d28aa056253bf6553b27982c14348a2d5).
     * This patch **fails Scala style 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146328464
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146314841
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43332/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146333798
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146330011
  
      [Test build #43347 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43347/consoleFull) for   PR 8990 at commit [`58fac13`](https://github.com/apache/spark/commit/58fac138eb2da3320bc8abb75eb0141d5de42d7b).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145699371
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146472078
  
      [Test build #43392 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43392/consoleFull) for   PR 8990 at commit [`a2a207b`](https://github.com/apache/spark/commit/a2a207b033170ecf74f78f339f51f2d6138dd32b).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145700612
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145700870
  
      [Test build #43264 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43264/consoleFull) for   PR 8990 at commit [`0e7e3e0`](https://github.com/apache/spark/commit/0e7e3e0086367535142c431b670e5e6ef1cf92d5).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146381892
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146067781
  
      [Test build #43310 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43310/console) for   PR 8990 at commit [`c388717`](https://github.com/apache/spark/commit/c388717c93c36dd956d0eef01597c104a542e4c6).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `case class CreateViewAsSelect(`



---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146003723
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43294/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41295949
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -563,6 +580,77 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
             }
           }
     
    +     case view @ Token("TOK_CREATEVIEW", children)
    +        if children.collect { case t @ Token("TOK_QUERY", _) => t }.nonEmpty =>
    +
    +      val Seq(
    +        Some(viewNameParts),
    +        Some(query),
    +        maybeComment,
    +        allowExisting,
    +        maybeProperties,
    +        maybeColumns,
    +        maybePartCols
    +      ) = getClauses(
    +        Seq(
    +          "TOK_TABNAME",
    +          "TOK_QUERY",
    +          "TOK_TABLECOMMENT",
    +          "TOK_IFNOTEXISTS",
    +          "TOK_TABLEPROPERTIES",
    +          "TOK_TABCOLNAME",
    +          "TOK_VIEWPARTCOLS"),
    +        children)
    +
    +      // If the view is partitioned, we let hive handle it.
    +      if (maybePartCols.isDefined) {
    +        NativePlaceholder
    +      } else {
    +        val (db, viewName) = extractDbNameTableName(viewNameParts)
    +
    +        val originalText = context.getTokenRewriteStream
    +          .toString(query.getTokenStartIndex, query.getTokenStopIndex)
    +
    +        val schema = maybeColumns.map { cols =>
    +          BaseSemanticAnalyzer.getColumns(cols, true).asScala.map { field =>
    +            HiveColumn(field.getName, field.getType, field.getComment)
    --- End diff --
    
    So, what will `field.getType` be at 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146385401
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146314778
  
      [Test build #43332 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43332/console) for   PR 8990 at commit [`d0a5d3e`](https://github.com/apache/spark/commit/d0a5d3e37be940f8fee8c166ef54032196cf580b).
     * This patch **fails Spark unit 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146314840
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on the pull request:

    https://github.com/apache/spark/pull/8990#issuecomment-146285841
  
    overall this LGTM, thanks for working on it.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146438007
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146316123
  
      [Test build #43334 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43334/console) for   PR 8990 at commit [`961c4a2`](https://github.com/apache/spark/commit/961c4a28d17e391a8c2a5767e1d402666ead859b).
     * This patch **fails Spark unit 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146630755
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145699560
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43262/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145699504
  
      [Test build #43262 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43262/consoleFull) for   PR 8990 at commit [`c427159`](https://github.com/apache/spark/commit/c427159f5784cb62fd709b5ec2a3429f37be0fd7).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146284304
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146003721
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146037099
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146292173
  
      [Test build #43334 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43334/consoleFull) for   PR 8990 at commit [`961c4a2`](https://github.com/apache/spark/commit/961c4a28d17e391a8c2a5767e1d402666ead859b).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146510450
  
      [Test build #43392 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43392/console) for   PR 8990 at commit [`a2a207b`](https://github.com/apache/spark/commit/a2a207b033170ecf74f78f339f51f2d6138dd32b).
     * 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146632471
  
      [Test build #43405 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43405/consoleFull) for   PR 8990 at commit [`d3eed7b`](https://github.com/apache/spark/commit/d3eed7bb684e2f79ab7a7f43b16f482f1b1910ef).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41300835
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -563,6 +580,77 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
             }
           }
     
    +     case view @ Token("TOK_CREATEVIEW", children)
    +        if children.collect { case t @ Token("TOK_QUERY", _) => t }.nonEmpty =>
    +
    +      val Seq(
    +        Some(viewNameParts),
    +        Some(query),
    +        maybeComment,
    +        allowExisting,
    +        maybeProperties,
    +        maybeColumns,
    +        maybePartCols
    +      ) = getClauses(
    +        Seq(
    +          "TOK_TABNAME",
    +          "TOK_QUERY",
    +          "TOK_TABLECOMMENT",
    +          "TOK_IFNOTEXISTS",
    +          "TOK_TABLEPROPERTIES",
    +          "TOK_TABCOLNAME",
    +          "TOK_VIEWPARTCOLS"),
    +        children)
    +
    +      // If the view is partitioned, we let hive handle it.
    +      if (maybePartCols.isDefined) {
    +        NativePlaceholder
    +      } else {
    +        val (db, viewName) = extractDbNameTableName(viewNameParts)
    +
    +        val originalText = context.getTokenRewriteStream
    +          .toString(query.getTokenStartIndex, query.getTokenStopIndex)
    +
    +        val schema = maybeColumns.map { cols =>
    +          BaseSemanticAnalyzer.getColumns(cols, true).asScala.map { field =>
    +            HiveColumn(field.getName, field.getType, field.getComment)
    --- End diff --
    
    Although it is not idea, let's use null for now. Let's add comments to here to explain that we will fix the type after the analysis phase. Also, let's add comments to HiveTable to explain that the type string is nullable.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146067831
  
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

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


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146328373
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:

    https://github.com/apache/spark/pull/8990#issuecomment-146627504
  
    LGTM. Just three minor comments.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146384275
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146067832
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43310/
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145976353
  
      [Test build #43294 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43294/consoleFull) for   PR 8990 at commit [`d54ec33`](https://github.com/apache/spark/commit/d54ec3389a5b072639494c041bbf5074a05b48d4).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146014456
  
      [Test build #43301 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43301/consoleFull) for   PR 8990 at commit [`8e1e4b8`](https://github.com/apache/spark/commit/8e1e4b830ad728eb0b0b8b097fc395b64d57516b).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146468910
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41418218
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateViewAsSelect.scala ---
    @@ -0,0 +1,77 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.hadoop.hive.ql.metadata.HiveUtils.{unparseIdentifier => verbose}
    +
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.hive.{HiveMetastoreTypes, HiveContext}
    +import org.apache.spark.sql.{AnalysisException, Row, SQLContext}
    +import org.apache.spark.sql.execution.RunnableCommand
    +import org.apache.spark.sql.hive.client.{HiveColumn, HiveTable}
    +
    +private[hive]
    +case class CreateViewAsSelect(
    --- End diff --
    
    Let's add scaladoc to this class. It's important to explain the limitation of this one (i.e. it does not canonicalize the entire sql text).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146663562
  
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146420903
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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/8990#discussion_r41540357
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
    @@ -588,6 +589,27 @@ private[hive] class HiveMetastoreCatalog(val client: ClientInterface, hive: Hive
           // Wait until children are resolved.
           case p: LogicalPlan if !p.childrenResolved => p
           case p: LogicalPlan if p.resolved => p
    +
    +      case CreateViewAsSelect(table, child, allowExisting, orReplace, sql) =>
    +        if (conf.canonicalizeView) {
    +          if (allowExisting && orReplace) {
    +            throw new AnalysisException("Can't combine IF NOT EXISTS and OR REPLACE.")
    --- End diff --
    
    The error message is copied from hive code... anyway I'll change it to make it more clear.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41540255
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -77,6 +77,16 @@ private[hive] case class CreateTableAsSelect(
         childrenResolved
     }
     
    +private[hive] case class CreateViewAsSelect(
    +    tableDesc: HiveTable,
    +    child: LogicalPlan,
    +    allowExisting: Boolean,
    +    orReplace: Boolean,
    --- End diff --
    
    Maybe `overwrite` or `replace` is a better name? `orReplace` is too tightly coupled with the sql syntax.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146438011
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43381/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41225160
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -563,6 +580,77 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
             }
           }
     
    +     case view @ Token("TOK_CREATEVIEW", children)
    +        if children.collect { case t @ Token("TOK_QUERY", _) => t }.nonEmpty =>
    +
    +      val Seq(
    +        Some(viewNameParts),
    +        Some(query),
    +        maybeComment,
    +        allowExisting,
    +        maybeProperties,
    +        maybeColumns,
    +        maybePartCols
    +      ) = getClauses(
    +        Seq(
    +          "TOK_TABNAME",
    +          "TOK_QUERY",
    +          "TOK_TABLECOMMENT",
    +          "TOK_IFNOTEXISTS",
    +          "TOK_TABLEPROPERTIES",
    +          "TOK_TABCOLNAME",
    +          "TOK_VIEWPARTCOLS"),
    +        children)
    +
    +      // If the view is partitioned, we let hive handle it.
    +      if (maybePartCols.isDefined) {
    +        NativePlaceholder
    +      } else {
    +        val (db, viewName) = extractDbNameTableName(viewNameParts)
    +
    +        val originalText = context.getTokenRewriteStream
    +          .toString(query.getTokenStartIndex, query.getTokenStopIndex)
    +
    +        val schema = maybeColumns.map { cols =>
    +          BaseSemanticAnalyzer.getColumns(cols, true).asScala.map { field =>
    +            HiveColumn(field.getName, field.getType, field.getComment)
    +          }
    +        }.getOrElse(Seq.empty[HiveColumn])
    +
    +        val properties = scala.collection.mutable.Map.empty[String, String]
    +
    +        maybeProperties.foreach {
    +          case Token("TOK_TABLEPROPERTIES", list :: Nil) =>
    +            properties ++= getProperties(list)
    +        }
    +
    +        maybeComment.foreach {
    +          case Token("TOK_TABLECOMMENT", child :: Nil) =>
    +            val comment = BaseSemanticAnalyzer.unescapeSQLString(child.getText)
    +            if (comment ne null) {
    +              properties += ("comment" -> comment)
    +            }
    +        }
    +
    +        val tableDesc = HiveTable(
    +          specifiedDatabase = db,
    +          name = viewName,
    +          schema = schema,
    +          partitionColumns = Seq.empty[HiveColumn],
    +          properties = properties.toMap,
    +          serdeProperties = Map[String, String](),
    +          tableType = VirtualView,
    +          location = None,
    +          inputFormat = None,
    +          outputFormat = None,
    +          serde = None,
    +          viewText = Some(originalText))
    +
    +        val sql = context.getTokenRewriteStream
    +          .toString(view.getTokenStartIndex, view.getTokenStopIndex)
    --- End diff --
    
    Let's add a comment at 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146510564
  
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146291123
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146437957
  
      [Test build #43381 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43381/console) for   PR 8990 at commit [`98fb88c`](https://github.com/apache/spark/commit/98fb88cb5090e9d4c373d8d17428cf0d1cf4802b).
     * This patch **fails Spark unit 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146473487
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145975845
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41426990
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateViewAsSelect.scala ---
    @@ -0,0 +1,88 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.hive.{HiveMetastoreTypes, HiveContext}
    +import org.apache.spark.sql.{AnalysisException, Row, SQLContext}
    +import org.apache.spark.sql.execution.RunnableCommand
    +import org.apache.spark.sql.hive.client.{HiveColumn, HiveTable}
    +
    +/**
    + * Create Hive view on non-hive-compatible tables by specifying schema ourselves instead of
    + * depending on Hive meta-store.
    + * Note that this class can NOT canonicalize the view SQL string entirely, which is different from
    + * Hive and may not work for some cases like create view on self join.
    --- End diff --
    
    Same here, leave a TODO.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146037066
  
      [Test build #43301 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43301/console) for   PR 8990 at commit [`8e1e4b8`](https://github.com/apache/spark/commit/8e1e4b830ad728eb0b0b8b097fc395b64d57516b).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `case class CreateViewAsSelect(`



---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145719535
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43264/
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41418669
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala ---
    @@ -1248,4 +1248,47 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
             """.stripMargin), Row("b", 6.0) :: Row("a", 7.0) :: Nil)
         }
       }
    +
    +  test("create hive view for json table") {
    +    // json table is not hive-compatible, make sure the new flag fix it.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("jt") {
    +        sqlContext.range(1, 10).write.format("json").saveAsTable("jt")
    +        sql("CREATE VIEW testView AS SELECT id FROM jt")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id"), (1 to 9).map(i => Row(i)))
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    +
    +  test("create hive view for partitioned parquet table") {
    +    // partitioned parquet table is not hive-compatible, make sure the new flag fix it.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("parTable") {
    +        val df = Seq(1 -> "a").toDF("i", "j")
    +        df.write.format("parquet").partitionBy("i").saveAsTable("parTable")
    +        sql("CREATE VIEW testView AS SELECT i, j FROM parTable")
    +        checkAnswer(sql("SELECT * FROM testView"), Row(1, "a"))
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    +
    +  test("create hive view for joined tables") {
    +    // make sure the new flag can handle some complex cases like join and schema change.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("jt1", "jt2") {
    +        sqlContext.range(1, 10).toDF("id1").write.format("json").saveAsTable("jt1")
    +        sqlContext.range(1, 10).toDF("id2").write.format("json").saveAsTable("jt2")
    +        sql("CREATE VIEW testView AS SELECT * FROM jt1 JOIN jt2 ON id1 == id2")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id1"), (1 to 9).map(i => Row(i, i)))
    +
    +        val df = (1 until 10).map(i => i -> i).toDF("id1", "newCol")
    +        df.write.format("json").mode(SaveMode.Overwrite).saveAsTable("jt1")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id1"), (1 to 9).map(i => Row(i, i)))
    +
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    --- End diff --
    
    It will be great to have tests to test out all paths of our parser (adding column names, column comments, properties, and etc. to the view definition). Also, what will happen if the name of view is defined as `dbName.viewName`?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146333801
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43347/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146510565
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43392/
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146421211
  
      [Test build #43381 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43381/consoleFull) for   PR 8990 at commit [`98fb88c`](https://github.com/apache/spark/commit/98fb88cb5090e9d4c373d8d17428cf0d1cf4802b).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145719534
  
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41416845
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateViewAsSelect.scala ---
    @@ -0,0 +1,77 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.hadoop.hive.ql.metadata.HiveUtils.{unparseIdentifier => verbose}
    +
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.hive.{HiveMetastoreTypes, HiveContext}
    +import org.apache.spark.sql.{AnalysisException, Row, SQLContext}
    +import org.apache.spark.sql.execution.RunnableCommand
    +import org.apache.spark.sql.hive.client.{HiveColumn, HiveTable}
    +
    +private[hive]
    +case class CreateViewAsSelect(
    +    tableDesc: HiveTable,
    +    childSchema: Seq[Attribute],
    +    allowExisting: Boolean) extends RunnableCommand {
    +
    +  assert(tableDesc.schema == Nil || tableDesc.schema.length == childSchema.length)
    +  assert(tableDesc.viewText.isDefined)
    +
    +  override def run(sqlContext: SQLContext): Seq[Row] = {
    +    val hiveContext = sqlContext.asInstanceOf[HiveContext]
    +    val database = tableDesc.database
    +    val viewName = tableDesc.name
    +    val viewText = tableDesc.viewText.get
    +
    +    if (hiveContext.catalog.tableExists(Seq(database, viewName))) {
    +      if (allowExisting) {
    +        // view already exists, will do nothing, to keep consistent with Hive
    +      } else {
    +        throw new AnalysisException(s"$database.$viewName already exists.")
    +      }
    +    } else {
    +      val schema = if (tableDesc.schema == Nil) {
    +        childSchema.map { attr =>
    +          HiveColumn(attr.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), null)
    +        }
    +      } else {
    +        childSchema.zip(tableDesc.schema).map { case (attr, col) =>
    +          HiveColumn(col.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), col.comment)
    +        }
    +      }
    +
    +      val columnNames = childSchema.map(f => verbose(f.name))
    --- End diff --
    
    Let's add a comment to explain what `verbose` does.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146399845
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43370/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41426883
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/ClientInterface.scala ---
    @@ -45,6 +45,7 @@ private[hive] case class HivePartition(
         values: Seq[String],
         storage: HiveStorageDescriptor)
     
    +// The `hiveType` is nullable, for cases like CREATE VIEW that can't specify column types.
    --- End diff --
    
    In other places in the codebase we use `@Nullable` for 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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41426940
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/ClientWrapper.scala ---
    @@ -354,6 +354,28 @@ private[hive] class ClientWrapper(
         qlTable
       }
     
    +  override def createView(view: HiveTable): Unit = withHiveState {
    +    // TODO: this is duplicated with `toQlTable` except the table type stuff.
    +    val tbl = new metadata.Table(view.database, view.name)
    +    tbl.setTableType(HTableType.VIRTUAL_VIEW)
    +    tbl.setSerializationLib(null)
    +    tbl.clearSerDeInfo()
    +
    +    // We will save the same SQL string to original and expanded text, which is different from Hive.
    +    tbl.setViewOriginalText(view.viewText.get)
    +    tbl.setViewExpandedText(view.viewText.get)
    --- End diff --
    
    Perhaps leave a TODO here so readers know this is not ideal.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41224328
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala ---
    @@ -319,6 +319,14 @@ private[spark] object SQLConf {
         doc = "When true, some predicates will be pushed down into the Hive metastore so that " +
               "unmatching partitions can be eliminated earlier.")
     
    +  val HIVE_NON_NATIVE_VIEW = booleanConf("spark.sql.hive.nonNativeView",
    +    defaultValue = Some(false),
    +    doc = "When true, CREATE VIEW will be handled by Spark SQL instead of Hive native commands.  " +
    +          "Note that this function is experimental and should ony be used when you are using " +
    +          "non-hive-compatible tables written by Spark SQL.  The SQL string used to create " +
    +          "view should be fully qualified, i.e. use `tbl1`.`col1` instead of `*` whenever " +
    +          "possible, or you may get wrong result.")
    --- End diff --
    
    how about `spark.sql.canonicalizeView`? Also, can we make it not a public conf? Hopefully, we will have the right mechanism to canonicalize view definitions later.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146630776
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146012318
  
    Merged build started.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146399756
  
      [Test build #43370 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43370/console) for   PR 8990 at commit [`44fcbf9`](https://github.com/apache/spark/commit/44fcbf93318e5ec677ce80b119b6bb5d13205c6a).
     * This patch **fails Spark unit 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145719458
  
      [Test build #43264 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43264/console) for   PR 8990 at commit [`0e7e3e0`](https://github.com/apache/spark/commit/0e7e3e0086367535142c431b670e5e6ef1cf92d5).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public class BufferHolder `
      * `public class UnsafeArrayWriter `
      * `public class UnsafeRowWriter `
      * `case class CreateViewAsSelect(`



---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41427063
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala ---
    @@ -1248,4 +1248,47 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
             """.stripMargin), Row("b", 6.0) :: Row("a", 7.0) :: Nil)
         }
       }
    +
    +  test("create hive view for json table") {
    +    // json table is not hive-compatible, make sure the new flag fix it.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("jt") {
    +        sqlContext.range(1, 10).write.format("json").saveAsTable("jt")
    +        sql("CREATE VIEW testView AS SELECT id FROM jt")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id"), (1 to 9).map(i => Row(i)))
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    +
    +  test("create hive view for partitioned parquet table") {
    +    // partitioned parquet table is not hive-compatible, make sure the new flag fix it.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("parTable") {
    +        val df = Seq(1 -> "a").toDF("i", "j")
    +        df.write.format("parquet").partitionBy("i").saveAsTable("parTable")
    +        sql("CREATE VIEW testView AS SELECT i, j FROM parTable")
    +        checkAnswer(sql("SELECT * FROM testView"), Row(1, "a"))
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    +
    +  test("create hive view for joined tables") {
    +    // make sure the new flag can handle some complex cases like join and schema change.
    +    withSQLConf(SQLConf.CANONICALIZE_VIEW.key -> "true") {
    +      withTable("jt1", "jt2") {
    +        sqlContext.range(1, 10).toDF("id1").write.format("json").saveAsTable("jt1")
    +        sqlContext.range(1, 10).toDF("id2").write.format("json").saveAsTable("jt2")
    +        sql("CREATE VIEW testView AS SELECT * FROM jt1 JOIN jt2 ON id1 == id2")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id1"), (1 to 9).map(i => Row(i, i)))
    +
    +        val df = (1 until 10).map(i => i -> i).toDF("id1", "newCol")
    +        df.write.format("json").mode(SaveMode.Overwrite).saveAsTable("jt1")
    +        checkAnswer(sql("SELECT * FROM testView ORDER BY id1"), (1 to 9).map(i => Row(i, i)))
    +
    +        sql("DROP VIEW testView")
    +      }
    +    }
    +  }
    --- End diff --
    
    still good to test :)


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145699358
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41540520
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateViewAsSelect.scala ---
    @@ -0,0 +1,95 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.hive.{HiveMetastoreTypes, HiveContext}
    +import org.apache.spark.sql.{AnalysisException, Row, SQLContext}
    +import org.apache.spark.sql.execution.RunnableCommand
    +import org.apache.spark.sql.hive.client.{HiveColumn, HiveTable}
    +
    +/**
    + * Create Hive view on non-hive-compatible tables by specifying schema ourselves instead of
    + * depending on Hive meta-store.
    + */
    +// TODO: Note that this class can NOT canonicalize the view SQL string entirely, which is different
    +// from Hive and may not work for some cases like create view on self join.
    +private[hive] case class CreateViewAsSelect(
    +    tableDesc: HiveTable,
    +    childSchema: Seq[Attribute],
    +    allowExisting: Boolean,
    +    orReplace: Boolean) extends RunnableCommand {
    +
    +  assert(tableDesc.schema == Nil || tableDesc.schema.length == childSchema.length)
    +  assert(tableDesc.viewText.isDefined)
    +
    +  override def run(sqlContext: SQLContext): Seq[Row] = {
    +    val hiveContext = sqlContext.asInstanceOf[HiveContext]
    +    val database = tableDesc.database
    +    val viewName = tableDesc.name
    +
    +    if (hiveContext.catalog.tableExists(Seq(database, viewName))) {
    +      if (allowExisting) {
    +        // view already exists, will do nothing, to keep consistent with Hive
    +      } else if (orReplace) {
    +        hiveContext.catalog.client.alertView(prepareTable())
    +      } else {
    +        throw new AnalysisException(s"$database.$viewName already exists.")
    --- End diff --
    
    Maybe `View $database.$viewName already exists. If you want to update the view definition, please use ALTER VIEW AS or CREATE OR REPLACE VIEW AS`?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146047865
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146385709
  
      [Test build #43370 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43370/consoleFull) for   PR 8990 at commit [`44fcbf9`](https://github.com/apache/spark/commit/44fcbf93318e5ec677ce80b119b6bb5d13205c6a).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146663563
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43405/
    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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145699559
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146285939
  
      [Test build #43332 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43332/consoleFull) for   PR 8990 at commit [`d0a5d3e`](https://github.com/apache/spark/commit/d0a5d3e37be940f8fee8c166ef54032196cf580b).


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41417365
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateViewAsSelect.scala ---
    @@ -0,0 +1,77 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.hadoop.hive.ql.metadata.HiveUtils.{unparseIdentifier => verbose}
    +
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.hive.{HiveMetastoreTypes, HiveContext}
    +import org.apache.spark.sql.{AnalysisException, Row, SQLContext}
    +import org.apache.spark.sql.execution.RunnableCommand
    +import org.apache.spark.sql.hive.client.{HiveColumn, HiveTable}
    +
    +private[hive]
    +case class CreateViewAsSelect(
    +    tableDesc: HiveTable,
    +    childSchema: Seq[Attribute],
    +    allowExisting: Boolean) extends RunnableCommand {
    +
    +  assert(tableDesc.schema == Nil || tableDesc.schema.length == childSchema.length)
    +  assert(tableDesc.viewText.isDefined)
    +
    +  override def run(sqlContext: SQLContext): Seq[Row] = {
    +    val hiveContext = sqlContext.asInstanceOf[HiveContext]
    +    val database = tableDesc.database
    +    val viewName = tableDesc.name
    +    val viewText = tableDesc.viewText.get
    +
    +    if (hiveContext.catalog.tableExists(Seq(database, viewName))) {
    +      if (allowExisting) {
    +        // view already exists, will do nothing, to keep consistent with Hive
    +      } else {
    +        throw new AnalysisException(s"$database.$viewName already exists.")
    +      }
    +    } else {
    +      val schema = if (tableDesc.schema == Nil) {
    +        childSchema.map { attr =>
    +          HiveColumn(attr.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), null)
    +        }
    +      } else {
    +        childSchema.zip(tableDesc.schema).map { case (attr, col) =>
    +          HiveColumn(col.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), col.comment)
    +        }
    +      }
    +
    +      val columnNames = childSchema.map(f => verbose(f.name))
    --- End diff --
    
    In Hive, `unparseIdentifier(String identifier)` will call `unparseIdentifier(String identifier, Configuration conf)` with `conf = null`. The implementation of `unparseIdentifier(String identifier, Configuration conf)` is
    ```
    public static String unparseIdentifier(String identifier, Configuration conf) {
      // In the future, if we support arbitrary characters in
      // identifiers, then we'll need to escape any backticks
      // in identifier by doubling them up.
    
      // the time has come
      String qIdSupport = conf == null ? null :
        HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_QUOTEDID_SUPPORT);
      if ( qIdSupport != null && !"none".equals(qIdSupport) ) {
        identifier = identifier.replaceAll("`", "``");
      }
      return "`" + identifier + "`";
    }
    ```
    
    It will escape a backtick with double-backtick. I guess we want to have the same behavior. Actually, can we inline that function (since it is very short)?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146316203
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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/8990#discussion_r41540476
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -77,6 +77,16 @@ private[hive] case class CreateTableAsSelect(
         childrenResolved
     }
     
    +private[hive] case class CreateViewAsSelect(
    +    tableDesc: HiveTable,
    +    child: LogicalPlan,
    +    allowExisting: Boolean,
    +    orReplace: Boolean,
    --- End diff --
    
    they are copied from hive code too... I'll update it


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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/8990#discussion_r41295186
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -563,6 +580,77 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
             }
           }
     
    +     case view @ Token("TOK_CREATEVIEW", children)
    +        if children.collect { case t @ Token("TOK_QUERY", _) => t }.nonEmpty =>
    +
    +      val Seq(
    +        Some(viewNameParts),
    +        Some(query),
    +        maybeComment,
    +        allowExisting,
    +        maybeProperties,
    +        maybeColumns,
    +        maybePartCols
    +      ) = getClauses(
    +        Seq(
    +          "TOK_TABNAME",
    +          "TOK_QUERY",
    +          "TOK_TABLECOMMENT",
    +          "TOK_IFNOTEXISTS",
    +          "TOK_TABLEPROPERTIES",
    +          "TOK_TABCOLNAME",
    +          "TOK_VIEWPARTCOLS"),
    +        children)
    +
    +      // If the view is partitioned, we let hive handle it.
    +      if (maybePartCols.isDefined) {
    +        NativePlaceholder
    +      } else {
    +        val (db, viewName) = extractDbNameTableName(viewNameParts)
    +
    +        val originalText = context.getTokenRewriteStream
    +          .toString(query.getTokenStartIndex, query.getTokenStopIndex)
    +
    +        val schema = maybeColumns.map { cols =>
    +          BaseSemanticAnalyzer.getColumns(cols, true).asScala.map { field =>
    +            HiveColumn(field.getName, field.getType, field.getComment)
    --- End diff --
    
    Hive only support specify column name and comment, see https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateView


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41416396
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateViewAsSelect.scala ---
    @@ -0,0 +1,77 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.hadoop.hive.ql.metadata.HiveUtils.{unparseIdentifier => verbose}
    +
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.hive.{HiveMetastoreTypes, HiveContext}
    +import org.apache.spark.sql.{AnalysisException, Row, SQLContext}
    +import org.apache.spark.sql.execution.RunnableCommand
    +import org.apache.spark.sql.hive.client.{HiveColumn, HiveTable}
    +
    +private[hive]
    +case class CreateViewAsSelect(
    +    tableDesc: HiveTable,
    +    childSchema: Seq[Attribute],
    +    allowExisting: Boolean) extends RunnableCommand {
    +
    +  assert(tableDesc.schema == Nil || tableDesc.schema.length == childSchema.length)
    +  assert(tableDesc.viewText.isDefined)
    +
    +  override def run(sqlContext: SQLContext): Seq[Row] = {
    +    val hiveContext = sqlContext.asInstanceOf[HiveContext]
    +    val database = tableDesc.database
    +    val viewName = tableDesc.name
    +    val viewText = tableDesc.viewText.get
    +
    +    if (hiveContext.catalog.tableExists(Seq(database, viewName))) {
    +      if (allowExisting) {
    +        // view already exists, will do nothing, to keep consistent with Hive
    +      } else {
    +        throw new AnalysisException(s"$database.$viewName already exists.")
    +      }
    +    } else {
    +      val schema = if (tableDesc.schema == Nil) {
    +        childSchema.map { attr =>
    +          HiveColumn(attr.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), null)
    +        }
    +      } else {
    +        childSchema.zip(tableDesc.schema).map { case (attr, col) =>
    +          HiveColumn(col.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), col.comment)
    --- End diff --
    
    Add a comment at here to explain we are attaching the real column types at 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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41417693
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/ClientWrapper.scala ---
    @@ -354,6 +354,25 @@ private[hive] class ClientWrapper(
         qlTable
       }
     
    +  override def createView(view: HiveTable): Unit = withHiveState {
    +    // TODO: this is duplicated with `toQlTable` except the table type stuff.
    +    val tbl = new metadata.Table(view.database, view.name)
    +    tbl.setTableType(HTableType.VIRTUAL_VIEW)
    +    tbl.setSerializationLib(null)
    +    tbl.clearSerDeInfo()
    +    tbl.setViewOriginalText(view.viewText.get)
    +    tbl.setViewExpandedText(view.viewText.get)
    --- End diff --
    
    Let's add a note at here to explain that we will save the same sql to original text and expanded text, which is not the case for Hive.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41225256
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -563,6 +580,77 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
             }
           }
     
    +     case view @ Token("TOK_CREATEVIEW", children)
    +        if children.collect { case t @ Token("TOK_QUERY", _) => t }.nonEmpty =>
    +
    +      val Seq(
    +        Some(viewNameParts),
    +        Some(query),
    +        maybeComment,
    +        allowExisting,
    +        maybeProperties,
    +        maybeColumns,
    +        maybePartCols
    +      ) = getClauses(
    +        Seq(
    +          "TOK_TABNAME",
    +          "TOK_QUERY",
    +          "TOK_TABLECOMMENT",
    +          "TOK_IFNOTEXISTS",
    +          "TOK_TABLEPROPERTIES",
    +          "TOK_TABCOLNAME",
    +          "TOK_VIEWPARTCOLS"),
    +        children)
    +
    +      // If the view is partitioned, we let hive handle it.
    +      if (maybePartCols.isDefined) {
    +        NativePlaceholder
    +      } else {
    +        val (db, viewName) = extractDbNameTableName(viewNameParts)
    +
    +        val originalText = context.getTokenRewriteStream
    +          .toString(query.getTokenStartIndex, query.getTokenStopIndex)
    +
    +        val schema = maybeColumns.map { cols =>
    +          BaseSemanticAnalyzer.getColumns(cols, true).asScala.map { field =>
    +            HiveColumn(field.getName, field.getType, field.getComment)
    --- End diff --
    
    Does hive allow column types specified in the create view command?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:

    https://github.com/apache/spark/pull/8990#issuecomment-146334125
  
    Let's also take a look at `ALTER VIEW AS SELECT` and `CREATE OR REPLACE VIEW`.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-145698931
  
    cc @yhuai @marmbrus 


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41540142
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
    @@ -588,6 +589,27 @@ private[hive] class HiveMetastoreCatalog(val client: ClientInterface, hive: Hive
           // Wait until children are resolved.
           case p: LogicalPlan if !p.childrenResolved => p
           case p: LogicalPlan if p.resolved => p
    +
    +      case CreateViewAsSelect(table, child, allowExisting, orReplace, sql) =>
    +        if (conf.canonicalizeView) {
    +          if (allowExisting && orReplace) {
    +            throw new AnalysisException("Can't combine IF NOT EXISTS and OR REPLACE.")
    --- End diff --
    
    Maybe `It is not allowed to define a view with both IF NOT EXISTS and OR REPLACE.`?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146385387
  
     Merged build triggered.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#discussion_r41417537
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateViewAsSelect.scala ---
    @@ -0,0 +1,77 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.hadoop.hive.ql.metadata.HiveUtils.{unparseIdentifier => verbose}
    +
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.hive.{HiveMetastoreTypes, HiveContext}
    +import org.apache.spark.sql.{AnalysisException, Row, SQLContext}
    +import org.apache.spark.sql.execution.RunnableCommand
    +import org.apache.spark.sql.hive.client.{HiveColumn, HiveTable}
    +
    +private[hive]
    +case class CreateViewAsSelect(
    +    tableDesc: HiveTable,
    +    childSchema: Seq[Attribute],
    +    allowExisting: Boolean) extends RunnableCommand {
    +
    +  assert(tableDesc.schema == Nil || tableDesc.schema.length == childSchema.length)
    +  assert(tableDesc.viewText.isDefined)
    +
    +  override def run(sqlContext: SQLContext): Seq[Row] = {
    +    val hiveContext = sqlContext.asInstanceOf[HiveContext]
    +    val database = tableDesc.database
    +    val viewName = tableDesc.name
    +    val viewText = tableDesc.viewText.get
    +
    +    if (hiveContext.catalog.tableExists(Seq(database, viewName))) {
    +      if (allowExisting) {
    +        // view already exists, will do nothing, to keep consistent with Hive
    +      } else {
    +        throw new AnalysisException(s"$database.$viewName already exists.")
    +      }
    +    } else {
    +      val schema = if (tableDesc.schema == Nil) {
    +        childSchema.map { attr =>
    +          HiveColumn(attr.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), null)
    +        }
    +      } else {
    +        childSchema.zip(tableDesc.schema).map { case (attr, col) =>
    +          HiveColumn(col.name, HiveMetastoreTypes.toMetastoreType(attr.dataType), col.comment)
    +        }
    +      }
    +
    +      val columnNames = childSchema.map(f => verbose(f.name))
    +      val projectList = if (tableDesc.schema == Nil) {
    --- End diff --
    
    Let's add a comment to explain why we need to create a project.


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:

    https://github.com/apache/spark/pull/8990#issuecomment-146665924
  
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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/8990#discussion_r41299272
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala ---
    @@ -563,6 +580,77 @@ https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation%2C+Cube%2C
             }
           }
     
    +     case view @ Token("TOK_CREATEVIEW", children)
    +        if children.collect { case t @ Token("TOK_QUERY", _) => t }.nonEmpty =>
    +
    +      val Seq(
    +        Some(viewNameParts),
    +        Some(query),
    +        maybeComment,
    +        allowExisting,
    +        maybeProperties,
    +        maybeColumns,
    +        maybePartCols
    +      ) = getClauses(
    +        Seq(
    +          "TOK_TABNAME",
    +          "TOK_QUERY",
    +          "TOK_TABLECOMMENT",
    +          "TOK_IFNOTEXISTS",
    +          "TOK_TABLEPROPERTIES",
    +          "TOK_TABCOLNAME",
    +          "TOK_VIEWPARTCOLS"),
    +        children)
    +
    +      // If the view is partitioned, we let hive handle it.
    +      if (maybePartCols.isDefined) {
    +        NativePlaceholder
    +      } else {
    +        val (db, viewName) = extractDbNameTableName(viewNameParts)
    +
    +        val originalText = context.getTokenRewriteStream
    +          .toString(query.getTokenStartIndex, query.getTokenStopIndex)
    +
    +        val schema = maybeColumns.map { cols =>
    +          BaseSemanticAnalyzer.getColumns(cols, true).asScala.map { field =>
    +            HiveColumn(field.getName, field.getType, field.getComment)
    --- End diff --
    
    it will always return null. Should I just use null literal to make it clear?


---
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: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146316207
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43334/
    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 pull request: [SPARK-10337][SQL] fix hive views on non-hive-...

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

    https://github.com/apache/spark/pull/8990#issuecomment-146470783
  
     Merged build triggered.


---
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