-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19329][SQL]Reading from or writing to a datasource table with a non pre-existing location should succeed #16672
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
Changes from 4 commits
5ec7dd6
2196648
abc57dd
c3439ff
409f7a4
542f86b
2cbb9d6
c3e87d3
5ebd596
334e89f
b238e8d
dee844c
0d947a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1431,4 +1431,30 @@ class HiveDDLSuite | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("insert data to a table which has altered the table location " + | ||
| "to an not exist location should success") { | ||
| withTable("t") { | ||
| withTempDir { dir => | ||
| spark.sql( | ||
| s"""create table t(a string, b int) | ||
|
||
| |using parquet | ||
| |options(path "${dir.getAbsolutePath}") | ||
| """.stripMargin) | ||
|
||
| var table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t")) | ||
|
||
| assert(table.location == dir.getAbsolutePath) | ||
|
|
||
| var newDir = dir.getAbsolutePath.stripSuffix("/") + "/x" | ||
| spark.sql(s"alter table t set location '$newDir'") | ||
|
|
||
| table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t")) | ||
| assert(table.location == newDir) | ||
| assert(!new File(newDir).exists()) | ||
| checkAnswer(spark.table("t"), Nil) | ||
|
|
||
| spark.sql("insert into table t select 'c', 1") | ||
| checkAnswer(spark.table("t"), Row("c", 1) :: Nil) | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
Test case names are not accurate after you add new test cases. Actually, could you split the test cases?