-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19575][SQL]Reading from or writing to a hive serde table with a non pre-existing location should succeed #16910
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
Closed
windpiger
wants to merge
17
commits into
apache:master
from
windpiger:selectHiveFromNotExistLocation
Closed
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cb98375
[SPARK-19575][SQL]Reading from or writing to a hive serde table with …
windpiger 401e86d
remove some comment
windpiger 4493a8f
mv the logic to makeRDDForTable
windpiger 6fb2b57
remove redundant import
windpiger b4caca7
fix a comment
windpiger 119fa64
modify some test case code
windpiger 3870e19
fix when the table is created by 'stored by'
windpiger 92d1067
replace the constant of STORAGE_HADNLER
windpiger 4f660d2
modfiy test case
windpiger 7aa43b1
modfiy test case
windpiger f83d81d
merge with master
windpiger 2456a94
fix test failed
windpiger f4b4d29
fix test failed
windpiger 3dcd6c6
modify some tests
windpiger 065af19
Merge branch 'master' into selectHiveFromNotExistLocation
windpiger a4f771a
merge with master
windpiger 15c0a77
add makeQualifiedPath func
windpiger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
modfiy test case
- Loading branch information
commit 4f660d2211d597aa64105f925b981d081449c58d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1496,19 +1496,19 @@ class HiveDDLSuite | |
| } | ||
| } | ||
|
|
||
| test("insert data to a hive serde table which has a not existed location should succeed") { | ||
| test("insert data to a hive serde table which has a non-existing location should succeed") { | ||
| withTable("t") { | ||
| withTempDir { dir => | ||
| val dirPath = dir.getAbsolutePath.stripSuffix("/") | ||
| spark.sql( | ||
| s""" | ||
| |CREATE TABLE t(a string, b int) | ||
| |USING hive | ||
| |OPTIONS(path "file:$dirPath") | ||
| |LOCATION '$dir' | ||
| """.stripMargin) | ||
| val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t")) | ||
| val expectedPath = s"file:$dirPath" | ||
| assert(table.location.stripSuffix("/") == expectedPath) | ||
| val dirPath = new Path(dir.getAbsolutePath) | ||
| val fs = dirPath.getFileSystem(spark.sessionState.newHadoopConf()) | ||
| assert(new Path(table.location) == fs.makeQualified(dirPath)) | ||
|
|
||
| val tableLocFile = new File(table.location.stripPrefix("file:")) | ||
|
||
| tableLocFile.delete() | ||
|
|
@@ -1539,20 +1539,20 @@ class HiveDDLSuite | |
| } | ||
| } | ||
|
|
||
| test("insert into a hive serde table with no existed partition location should succeed") { | ||
| test("insert into a hive serde table with non-existing partition location should succeed") { | ||
| withTable("t") { | ||
| withTempDir { dir => | ||
| val dirPath = dir.getAbsolutePath.stripSuffix("/") | ||
| spark.sql( | ||
| s""" | ||
| |CREATE TABLE t(a int, b int, c int, d int) | ||
| |USING hive | ||
| |PARTITIONED BY(a, b) | ||
| |LOCATION "file:$dirPath" | ||
| |LOCATION "$dir" | ||
| """.stripMargin) | ||
| val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t")) | ||
| val expectedPath = s"file:$dirPath" | ||
| assert(table.location.stripSuffix("/") == expectedPath) | ||
| val dirPath = new Path(dir.getAbsolutePath) | ||
| val fs = dirPath.getFileSystem(spark.sessionState.newHadoopConf()) | ||
| assert(new Path(table.location) == fs.makeQualified(dirPath)) | ||
|
|
||
| spark.sql("INSERT INTO TABLE t PARTITION(a=1, b=2) SELECT 3, 4") | ||
| checkAnswer(spark.table("t"), Row(3, 4, 1, 2) :: Nil) | ||
|
|
@@ -1578,19 +1578,19 @@ class HiveDDLSuite | |
| } | ||
| } | ||
|
|
||
| test("read data from a hive serde table which has a not existed location should succeed") { | ||
| test("read data from a hive serde table which has a non-existing location should succeed") { | ||
| withTable("t") { | ||
| withTempDir { dir => | ||
| val dirPath = dir.getAbsolutePath.stripSuffix("/") | ||
| spark.sql( | ||
| s""" | ||
| |CREATE TABLE t(a string, b int) | ||
| |USING hive | ||
| |OPTIONS(path "file:${dir.getAbsolutePath}") | ||
| |LOCATION "$dir" | ||
| """.stripMargin) | ||
| val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t")) | ||
| val expectedPath = s"file:$dirPath" | ||
| assert(table.location.stripSuffix("/") == expectedPath) | ||
| val dirPath = new Path(dir.getAbsolutePath) | ||
| val fs = dirPath.getFileSystem(spark.sessionState.newHadoopConf()) | ||
| assert(new Path(table.location) == fs.makeQualified(dirPath)) | ||
|
|
||
| dir.delete() | ||
| checkAnswer(spark.table("t"), Nil) | ||
|
|
@@ -1607,7 +1607,7 @@ class HiveDDLSuite | |
| } | ||
| } | ||
|
|
||
| test("read data from a hive serde table with no existed partition location should succeed") { | ||
| test("read data from a hive serde table with non-existing partition location should succeed") { | ||
| withTable("t") { | ||
| withTempDir { dir => | ||
| spark.sql( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 we just call
dir.deletebefore creating this table?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.
ok~
Uh oh!
There was an error while loading. Please reload this page.
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.
@cloud-fan I found the dir will be created in
create table, so we should keep current logic.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.
does hive have the same behavior?
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.
yes, I test it in Hive
then
hdfs:/xxwill be createdThere 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.
seems the
InMemoryCatalogdoesn't do this, you can send a new PR to fix it.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.
ok thanks~