-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19723][SQL]create datasource table with an non-existent location should work #17055
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 1 commit
89eb03a
0e09b92
d4378dd
4c82dfb
3ea3e9d
b26cce1
6f7045c
d53f7ab
3ae5b2a
bc7f08d
5699059
207448d
4024d7c
e1c891e
ada275c
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 |
|---|---|---|
|
|
@@ -1952,4 +1952,49 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach { | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("create datasource table with an non-existent location") { | ||
| withTable("t", "t1") { | ||
| withTempDir { | ||
| dir => | ||
| dir.delete() | ||
|
||
| spark.sql( | ||
| s""" | ||
| |CREATE TABLE t(a int, b int) | ||
| |USING parquet | ||
| |LOCATION '$dir' | ||
| """.stripMargin) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case is already pretty long. Please reduce the sql statement to a single line. |
||
|
|
||
| val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t")) | ||
| assert(table.location.stripSuffix("/") == dir.getAbsolutePath.stripSuffix("/")) | ||
|
|
||
| spark.sql("INSERT INTO TABLE t SELECT 1, 2") | ||
| assert(dir.exists()) | ||
|
|
||
| checkAnswer(spark.table("t"), Row(1, 2)) | ||
| } | ||
| // partition table | ||
| withTempDir { | ||
| dir => | ||
| dir.delete() | ||
| spark.sql( | ||
| s""" | ||
| |CREATE TABLE t1(a int, b int) | ||
| |USING parquet | ||
| |PARTITIONED BY(a) | ||
| |LOCATION '$dir' | ||
| """.stripMargin) | ||
|
|
||
| val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t1")) | ||
| assert(table.location.stripSuffix("/") == dir.getAbsolutePath.stripSuffix("/")) | ||
|
|
||
| spark.sql("INSERT INTO TABLE t1 PARTITION(a=1) SELECT 2") | ||
|
|
||
| val partDir = new File(dir, "a=1") | ||
| assert(partDir.exists()) | ||
|
|
||
| checkAnswer(spark.table("t1"), Row(2, 1)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
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: style issue. the above two lines can be combined together.