-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-15711][SQL] Ban CREATE TEMPORARY TABLE USING AS SELECT #13451
Conversation
e48caf0
to
fa1db6a
Compare
Looks good. Can you add a test for the new exception that you throw? |
Test build #59770 has finished for PR 13451 at commit
|
Test build #59776 has finished for PR 13451 at commit
|
@@ -1104,4 +1104,22 @@ class MetastoreDataSourcesSuite extends QueryTest with SQLTestUtils with TestHiv | |||
} | |||
} | |||
} | |||
|
|||
test("CTAS: disallow create temporary table ... using ... as ...") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this test case to HiveDDLCommandSuite
, which contains the Hive-specific parser test cases? You also can see the other CTAS test cases there. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gatorsmile Thanks. The test should be included in CreateTableAsSelectSuite
HiveDDLCommandSuite contains "create table as select", CreateTableAsSelectSuite contains "create table ... using ... as select ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, parser-specific test cases are put in the same suite. I am fine if you put it to the CTAS-specific test suite, especially when we will support it in the near future.
b7bb43d
to
90fb80a
Compare
90fb80a
to
2f0355f
Compare
|
||
checkAnswer( | ||
sql("SELECT a, b FROM jsonTable"), | ||
sql("SELECT a, b FROM jt").collect()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you do not need to call collect
LGTM except some minor issues which are already pointed out by others. |
Thanks @gatorsmile |
LGTM. Thanks! |
Test build #59818 has finished for PR 13451 at commit
|
Test build #59822 has finished for PR 13451 at commit
|
Test build #59828 has finished for PR 13451 at commit
|
Test build #59830 has finished for PR 13451 at commit
|
Test build #59834 has finished for PR 13451 at commit
|
@@ -317,17 +317,19 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder { | |||
// Get the backing query. | |||
val query = plan(ctx.query) | |||
|
|||
if (temp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can you please rename this to temporary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not in the scope of this PR, temp is a existing variable defined at https://github.com/clockfly/spark/blob/aaca7f01882de19c9dda47500f7d4f03712d3383/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala#L304.
@andrewor14 Could you please help sign off this one? Thanks! |
LGTM! |
Merging into amster 2.0 |
## What changes were proposed in this pull request? This PR bans syntax like `CREATE TEMPORARY TABLE USING AS SELECT` `CREATE TEMPORARY TABLE ... USING ... AS ...` is not properly implemented, the temporary data is not cleaned up when the session exits. Before a full fix, we probably should ban this syntax. This PR only impact syntax like `CREATE TEMPORARY TABLE ... USING ... AS ...`. Other syntax like `CREATE TEMPORARY TABLE .. USING ...` and `CREATE TABLE ... USING ...` are not impacted. ## How was this patch tested? Unit test. Author: Sean Zhong <seanzhong@databricks.com> Closes #13451 from clockfly/ban_create_temp_table_using_as. (cherry picked from commit d109a1b) Signed-off-by: Andrew Or <andrew@databricks.com>
What changes were proposed in this pull request?
This PR bans syntax like
CREATE TEMPORARY TABLE USING AS SELECT
CREATE TEMPORARY TABLE ... USING ... AS ...
is not properly implemented, the temporary data is not cleaned up when the session exits. Before a full fix, we probably should ban this syntax.This PR only impact syntax like
CREATE TEMPORARY TABLE ... USING ... AS ...
.Other syntax like
CREATE TEMPORARY TABLE .. USING ...
andCREATE TABLE ... USING ...
are not impacted.How was this patch tested?
Unit test.