You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by yhuai <gi...@git.apache.org> on 2016/05/29 18:32:47 UTC
[GitHub] spark pull request: [SPARK-14507] [SQL] EXTERNAL keyword in a CTAS...
GitHub user yhuai opened a pull request:
https://github.com/apache/spark/pull/13395
[SPARK-14507] [SQL] EXTERNAL keyword in a CTAS statement is not allowed
## What changes were proposed in this pull request?
This PR makes the parser to throw an exception if a hive style CTAS command has an external keyword. The main reason of this change is to make the syntax consistent with CREATE TABLE USING AS SELECT syntax (it does not allow EXTERNAL keyword).
Another options is to make `EXTERNAL` keyword optional.
## How was this patch tested?
HiveDDLCommandSuite
**NOTE: This PR is based on https://github.com/apache/spark/pull/13386, which needs to be merged first.**
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/yhuai/spark SPARK-14507-1
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13395.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 #13395
----
commit f613d9e6687ac306f54d2e82276561ec5eb6a1ac
Author: Yin Huai <yh...@databricks.com>
Date: 2016-05-28T23:18:49Z
test cases
commit 1e22d53cb2089841cc4dba4dd71066bb9915c9d6
Author: Yin Huai <yh...@databricks.com>
Date: 2016-05-28T23:19:45Z
Move the conversion logic to the parser.
commit 2615f676844d19b33552f60cd2849522d5564360
Author: Yin Huai <yh...@databricks.com>
Date: 2016-05-28T23:32:05Z
Update tests
commit c5cb32cf98248a1941c16b9ed605780f20cbca75
Author: Yin Huai <yh...@databricks.com>
Date: 2016-05-29T04:46:08Z
Hive style CTAS command does not allow EXTERNAL keyword and PARTITIONED BY clause.
commit 220a6e0d76f110f6423d96ce0b25e29e8fcb19f9
Author: Yin Huai <yh...@databricks.com>
Date: 2016-05-29T17:47:49Z
wip
commit fa8908122a238d6cdc0a9fc0f003221ef5601565
Author: Yin Huai <yh...@databricks.com>
Date: 2016-05-29T18:18:47Z
Changes related to EXTERNAL will be handled in another PR.
commit 27332df39b36e781c311b35383338f5deb478eea
Author: Yin Huai <yh...@databricks.com>
Date: 2016-05-29T18:26:28Z
[SPARK-14507] [SQL] EXTERNAL keyword in a CTAS statement is not allowed
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-14507] [SQL] EXTERNAL keyword in a CTAS statement...
Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the pull request:
https://github.com/apache/spark/pull/13395
uh, I see. Thanks!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222380672
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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/13395#discussion_r65013574
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
@@ -936,7 +936,47 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
comment = comment)
selectQuery match {
- case Some(q) => CreateTableAsSelectLogicalPlan(tableDesc, q, ifNotExists)
+ case Some(q) =>
+ // Hive does not allow to use a CTAS statement to create a partitioned table.
+ if (tableDesc.partitionColumnNames.nonEmpty) {
+ val errorMessage = "A Create Table As Select (CTAS) statement is not allowed to " +
+ "create a partitioned table using Hive's file formats. " +
--- End diff --
oh, at here, `Hive's file formats` means formats using Hive's SerDes. For data source tables, their readers/writers have native implementations in Spark instead of relying on Hive's SerDes. We can be more specific 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-14507] [SQL] EXTERNAL keyword in a CTAS statement...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:
https://github.com/apache/spark/pull/13395
@gatorsmile Thanks. For partitioned by, it is in https://github.com/apache/spark/pull/13386. For clustered by, seems we do have test case in HiveDDLCommandSuite.
---
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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222376429
**[Test build #59596 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59596/consoleFull)** for PR 13395 at commit [`27332df`](https://github.com/apache/spark/commit/27332df39b36e781c311b35383338f5deb478eea).
---
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-14507] [SQL] EXTERNAL keyword in a CTAS statement...
Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the pull request:
https://github.com/apache/spark/pull/13395
Just realized you are working on all the restrictions of CTAS. Based on the [official document of Hive](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableAsSelect(CTAS)), CTAS has three restrictions:
- The target table cannot be a partitioned table.
- The target table cannot be an external table.
- The target table cannot be a list bucketing table.
I have two test cases you can put in `DDLCommandSuite`:
```scala
test("CTAS - PARTITIONED BY is not supported") {
assertUnsupported(
sql = "CREATE TABLE my_tab(a double, b double) PARTITIONED BY (a STRING) " +
"AS SELECT key, value FROM mytable1")
}
test("CTAS - Bucketing is not supported") {
assertUnsupported(
sql = "CREATE TABLE my_tab(a double, b double) " +
"CLUSTERED BY (a) SORTED BY (b) INTO 5 BUCKETS AS SELECT key, value FROM mytable1")
}
```
---
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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222376022
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/59595/
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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222376014
**[Test build #59595 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59595/consoleFull)** for PR 13395 at commit [`27332df`](https://github.com/apache/spark/commit/27332df39b36e781c311b35383338f5deb478eea).
* 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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222380607
**[Test build #59596 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59596/consoleFull)** for PR 13395 at commit [`27332df`](https://github.com/apache/spark/commit/27332df39b36e781c311b35383338f5deb478eea).
* 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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222375644
**[Test build #59595 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59595/consoleFull)** for PR 13395 at commit [`27332df`](https://github.com/apache/spark/commit/27332df39b36e781c311b35383338f5deb478eea).
---
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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222376021
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-14507] [SQL] EXTERNAL keyword in a CTAS statement...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai closed the pull request at:
https://github.com/apache/spark/pull/13395
---
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-14507] [SQL] EXTERNAL keyword in a CTAS statement...
Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/13395#discussion_r65255370
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
@@ -936,7 +936,47 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
comment = comment)
selectQuery match {
- case Some(q) => CreateTableAsSelectLogicalPlan(tableDesc, q, ifNotExists)
+ case Some(q) =>
+ // Hive does not allow to use a CTAS statement to create a partitioned table.
+ if (tableDesc.partitionColumnNames.nonEmpty) {
+ val errorMessage = "A Create Table As Select (CTAS) statement is not allowed to " +
--- End diff --
I think it's OK to just leave this; CTAS is a pretty common term
---
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-14507] [SQL] EXTERNAL keyword in a CTAS statement...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:
https://github.com/apache/spark/pull/13395
chatted with @andrewor14 . Since https://github.com/apache/spark/pull/13386/files will fix the location handling when convertCTAS is true, probably it is not really needed to ban EXTERNAL keyword (also, hive's syntax support external for a regular create table 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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222380673
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/59596/
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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:
https://github.com/apache/spark/pull/13395#issuecomment-222376388
test this please
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by tejasapatil <gi...@git.apache.org>.
Github user tejasapatil commented on a diff in the pull request:
https://github.com/apache/spark/pull/13395#discussion_r65013342
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
@@ -936,7 +936,47 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
comment = comment)
selectQuery match {
- case Some(q) => CreateTableAsSelectLogicalPlan(tableDesc, q, ifNotExists)
+ case Some(q) =>
+ // Hive does not allow to use a CTAS statement to create a partitioned table.
+ if (tableDesc.partitionColumnNames.nonEmpty) {
+ val errorMessage = "A Create Table As Select (CTAS) statement is not allowed to " +
--- End diff --
nit: `CREATE TABLE ... AS SELECT ` to be consistent with other places.
---
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-14507] [SQL] EXTERNAL keyword in a CTAS...
Posted by tejasapatil <gi...@git.apache.org>.
Github user tejasapatil commented on a diff in the pull request:
https://github.com/apache/spark/pull/13395#discussion_r65013372
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
@@ -936,7 +936,47 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder {
comment = comment)
selectQuery match {
- case Some(q) => CreateTableAsSelectLogicalPlan(tableDesc, q, ifNotExists)
+ case Some(q) =>
+ // Hive does not allow to use a CTAS statement to create a partitioned table.
+ if (tableDesc.partitionColumnNames.nonEmpty) {
+ val errorMessage = "A Create Table As Select (CTAS) statement is not allowed to " +
+ "create a partitioned table using Hive's file formats. " +
--- End diff --
Does dataSource support creating tables with Hive file formats (parquet, orc etc..) ? I think it does. Then `Hive's file formats` might be a bit misleading.
---
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