Uh oh!
There was an error while loading. Please reload this page.
[SPARK-19115] [SQL] Supporting Create External Table Like Location - #16638
[SPARK-19115] [SQL] Supporting Create External Table Like Location#16638ouyangxiaochen wants to merge 7 commits into
Conversation
gatorsmile
commented
Jan 19, 2017
Could you follow the title requirement in http://spark.apache.org/contributing.html? |
| @@ -58,6 +58,7 @@ import org.apache.spark.util.Utils | |||
| case class CreateTableLikeCommand( | |||
There was a problem hiding this comment.
Please update the comment of this class.
There was a problem hiding this comment.
ok,i will update it later,Thanks!
We have a few test cases you can follow. Please create test cases. Thanks! |
gatorsmile
commented
Jan 19, 2017
In the PR, you might need to consider more scenarios. For example, let me ask a question. How does Hive behave when the specified location is not empty? |
ouyangxiaochen
commented
Jan 19, 2017
Here is the differences between Hive and Spark2.x as follow: 2.Spark2.x: So,this PR follows the spark2.x‘s design rules,thanks! |
First, please change the PR title to |
gatorsmile
commented
Jan 23, 2017
Let me rephrase it. If the directory specified in the |
gatorsmile
commented
Jan 23, 2017
Please keep updating your PR description. For example, this PR is not relying on |
ouyangxiaochen
commented
Jan 23, 2017
I am sorry that I did't grasp the key points of your question. In Hive, if there are data files under the specified path while creating an external table, then Hive will identify the files as table data files. |
| val sourceTable = visitTableIdentifier(ctx.source) | ||
| CreateTableLikeCommand(targetTable, sourceTable, ctx.EXISTS != null) | ||
| val location = Option(ctx.locationSpec).map(visitLocationSpec) | ||
| if (ctx.EXTERNAL != null && location.isEmpty) { |
There was a problem hiding this comment.
Add a comment above this line:
// If we are creating an EXTERNAL table, then the LOCATION field is required
There was a problem hiding this comment.
OK, I'll do it later, Thanks!
| val location = Option(ctx.locationSpec).map(visitLocationSpec) | ||
| if (ctx.EXTERNAL != null && location.isEmpty) { | ||
| operationNotAllowed("CREATE EXTERNAL TABLE LIKE must be accompanied by LOCATION", ctx) | ||
| } |
There was a problem hiding this comment.
To the other reviewers, we are following what we did in visitCreateHiveTable
gatorsmile
commented
Jan 24, 2017
@ouyangxiaochen Please do not duplicate the test cases. Try to combine them. @cloud-fan@yhuai Could you please check whether such a DDL support is desirable? |
gatorsmile
commented
Jan 24, 2017
ok to test. |
SparkQA
commented
Jan 24, 2017
Test build #71887 has finished for PR 16638 at commit
|
…ala file. 2. repair the error for test cases in HiveDDLSuite.scala file, sql statements lost a pair of single quotes.
ouyangxiaochen
commented
Jan 24, 2017
I have fixed the error of test cases and they run successfully. So,please run the test cases again.Thanks a lot! @SparkQA |
| (AS? query)? #createHiveTable | ||
| | CREATE TABLE (IF NOT EXISTS)? target=tableIdentifier | ||
| LIKE source=tableIdentifier #createTableLike | ||
| | CREATE EXTERNAL? TABLE (IF NOT EXISTS)? target=tableIdentifier |
There was a problem hiding this comment.
since Spark 2.2, we wanna hide the manage/external concept from users. It looks reasonable to add a LOCATION statement in CREATE TABLE LIKE, but do we really need the EXTERNAL keyword? We don't need to be exactly same with hive.
There was a problem hiding this comment.
ok then let's simplify the logic: if location is specified, we create an external table internally. Else, create managed table.
SparkQA
commented
Jan 24, 2017
Test build #71904 has finished for PR 16638 at commit
|
gatorsmile
commented
Jan 25, 2017
ping @ouyangxiaochen : ) |
ouyangxiaochen
commented
Feb 6, 2017
Happy Chinese New Year ! @gatorsmile |
ouyangxiaochen
commented
Feb 7, 2017
ping @gatorsmile |
cloud-fan
commented
Feb 7, 2017
please address #16638 (comment) |
2.simplify the logic: if location is specified, we create an external table internally. Else, create managed table 3.update test cases
| * {{{ | ||
| * CREATE TABLE [IF NOT EXISTS] [db_name.]table_name | ||
| * LIKE [other_db_name.]existing_table_name | ||
| * CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name |
| val v1 = "CREATE TABLE table1 LIKE table2" | ||
| val (target, source, exists) = parser.parsePlan(v1).collect { | ||
| case CreateTableLikeCommand(t, s, allowExisting) => (t, s, allowExisting) | ||
| val (target, source, location, exists) = parser.parsePlan(v1).collect { |
There was a problem hiding this comment.
add an assert to check location is empty
| @@ -528,8 +528,8 @@ class HiveDDLCommandSuite extends PlanTest with SQLTestUtils with TestHiveSingle | |||
| assert(source.table == "table2") | |||
| val v2 = "CREATE TABLE IF NOT EXISTS table1 LIKE table2" | |||
There was a problem hiding this comment.
add one more test case to check CREATE TABLE LIKE with location
| TableIdentifier(targetTabName, Some("default"))) | ||
| checkCreateTableLike(sourceTable, targetTable) | ||
| test("CREATE TABLE LIKE a temporary view [LOCATION]...") { |
There was a problem hiding this comment.
actually we don't need to change the test name
| checkCreateTableLike(sourceTable, targetTable) | ||
| test("CREATE TABLE LIKE a temporary view [LOCATION]...") { | ||
| var createdTableType = "MANAGED" | ||
| for ( i <- 0 to 1 ) { |
There was a problem hiding this comment.
you can create a method with parameter location: Option[String], instead of writing a for loop with 2 iterations...
There was a problem hiding this comment.
I write this for the purpose of reusing this piece of public code, because the basic logic of these two scenarios are almost the same.
There was a problem hiding this comment.
creating a method and wrap this piece of code can also reuse the code.
| private def checkCreateTableLike( | ||
| sourceTable: CatalogTable, | ||
| targetTable: CatalogTable, | ||
| tableType: String): Unit = { |
There was a problem hiding this comment.
why not pass in a CataogTableType instead of a string?
cloud-fan
commented
Feb 8, 2017
please resolve the conflict too, thanks! |
SparkQA
commented
Feb 8, 2017
Test build #72550 has finished for PR 16638 at commit
|
ouyangxiaochen
commented
Feb 8, 2017
I met some troubles when I resolving the conflict, So can u give me some guidances? Thanks a lot! @cloud-fan |
cloud-fan
commented
Feb 8, 2017
you can start with a new branch and apply the changes manually, e.g. copy code from this PR to the new branch. |
SparkQA
commented
Feb 8, 2017
Test build #72576 has finished for PR 16638 at commit
|
Should I delete my remote master repository firstly,and fork a new one again? @cloud-fan |
gatorsmile
commented
Feb 9, 2017
Your master is clean (i.e., exactly identical to the upstream/master), right? |
ouyangxiaochen
commented
Feb 9, 2017
My master branch with the master of Apache is not synchronized, and then I did the pull operation, my master branch still not synchronized, and finally I removed my remote repository. |
gatorsmile
commented
Feb 9, 2017
You might not be familiar with the Github/Git. How about submitting a new PR? : ) |
ouyangxiaochen
commented
Feb 9, 2017
Here's how I create a PR: |
gatorsmile
commented
Feb 9, 2017
You do not need to do the step 1 every time. You might miss the following two steps when you want to resolve your conflicts.
|
ouyangxiaochen
commented
Feb 9, 2017
Oh, I See, I miss a step ’git remote add upstream ...‘. |
gatorsmile
commented
Feb 9, 2017
No worry, open/submit a new PR. : ) |
You might be able to make it by forcefully pushing the new changes by |
ouyangxiaochen
commented
Feb 9, 2017
OK. I'll try it immediately. Thank U very much! |
ouyangxiaochen
commented
Feb 9, 2017
I have created a PR at https://github.com/apache/spark/pull/16868, please review it, Thanks! @gatorsmile@cloud-fan |
Closesapache#11785Closesapache#13027Closesapache#13614Closesapache#13761Closesapache#15197Closesapache#14006Closesapache#12576Closesapache#15447Closesapache#13259Closesapache#15616Closesapache#14473Closesapache#16638Closesapache#16146Closesapache#17269Closesapache#17313Closesapache#17418Closesapache#17485Closesapache#17551Closesapache#17463Closesapache#17625Closesapache#10739Closesapache#15193Closesapache#15344Closesapache#14804Closesapache#16993Closesapache#17040Closesapache#15180Closesapache#17238
This pr proposed to close stale PRs. Currently, we have 400+ open PRs and there are some stale PRs whose JIRA tickets have been already closed and whose JIRA tickets does not exist (also, they seem not to be minor issues). // Open PRs whose JIRA tickets have been already closed Closesapache#11785Closesapache#13027Closesapache#13614Closesapache#13761Closesapache#15197Closesapache#14006Closesapache#12576Closesapache#15447Closesapache#13259Closesapache#15616Closesapache#14473Closesapache#16638Closesapache#16146Closesapache#17269Closesapache#17313Closesapache#17418Closesapache#17485Closesapache#17551Closesapache#17463Closesapache#17625 // Open PRs whose JIRA tickets does not exist and they are not minor issues Closesapache#10739Closesapache#15193Closesapache#15344Closesapache#14804Closesapache#16993Closesapache#17040Closesapache#15180Closesapache#17238 N/A Author: Takeshi Yamamuro <yamamuro@apache.org> Closesapache#17734 from maropu/resolved_pr. Change-Id: Id2e590aa7283fe5ac01424d30a40df06da6098b5
## What changes were proposed in this pull request? This pr proposed to close stale PRs. Currently, we have 400+ open PRs and there are some stale PRs whose JIRA tickets have been already closed and whose JIRA tickets does not exist (also, they seem not to be minor issues). // Open PRs whose JIRA tickets have been already closed Closesapache#11785Closesapache#13027Closesapache#13614Closesapache#13761Closesapache#15197Closesapache#14006Closesapache#12576Closesapache#15447Closesapache#13259Closesapache#15616Closesapache#14473Closesapache#16638Closesapache#16146Closesapache#17269Closesapache#17313Closesapache#17418Closesapache#17485Closesapache#17551Closesapache#17463Closesapache#17625 // Open PRs whose JIRA tickets does not exist and they are not minor issues Closesapache#10739Closesapache#15193Closesapache#15344Closesapache#14804Closesapache#16993Closesapache#17040Closesapache#15180Closesapache#17238 ## How was this patch tested? N/A Author: Takeshi Yamamuro <yamamuro@apache.org> Closesapache#17734 from maropu/resolved_pr.
What changes were proposed in this pull request?
Support CREATE [EXTERNAL] TABLE LIKE LOCATION... syntax for Hive tables.
In this PR,we follow SparkSQL design rules :
How was this patch tested?
Add new test cases and update existing test cases