Uh oh!
There was an error while loading. Please reload this page.
[SPARK-19575][SQL]Reading from or writing to a hive serde table with a non pre-existing location should succeed - #16910
Conversation
…a non pre-existing location should succeed
SparkQA
commented
Feb 13, 2017
Test build #72808 has started for PR 16910 at commit |
windpiger
commented
Feb 13, 2017
retest this please |
SparkQA
commented
Feb 13, 2017
Test build #72812 has finished for PR 16910 at commit
|
windpiger
commented
Feb 13, 2017
SparkQA
commented
Feb 13, 2017
Test build #72815 has finished for PR 16910 at commit
|
@gatorsmile could you help to review this? thanks :) |
| dir.delete() | ||
| checkAnswer(spark.table("t"), Nil) | ||
| val newDir = dir.getAbsolutePath.stripSuffix("/") + "/x" |
| } | ||
| } | ||
| test("read data from a hive serde table which has a not existed location should succeed") { |
There was a problem hiding this comment.
This is the only test case failed without this fix. Right?
| s""" | ||
| |CREATE TABLE t(a string, b int) | ||
| |USING hive | ||
| |OPTIONS(path "file:${dir.getAbsolutePath}") |
| // if the table location is not exists, return an empty RDD | ||
| if (!fs.exists(locationPath)) { | ||
| return new EmptyRDD[InternalRow](sparkSession.sparkContext) |
There was a problem hiding this comment.
Can we do it in makeRDDForTable?
There was a problem hiding this comment.
I do it here for both non-partition table and partition table,while the partition table run well when the location does not exist with verifyPartitionPath set true,If we also want to run well when verifyPartitionPath set false, we should also do it in makeRDDForPartitionTable, then under this situation I do it here for both non-partition table and partition table.
There was a problem hiding this comment.
It seems not reasonable to do this for partition table, because the real partition path maybe not under the location of the partition table, I moved this logic to makeRDDForTable
SparkQA
commented
Feb 21, 2017
Test build #73191 has finished for PR 16910 at commit
|
gatorsmile
commented
Feb 21, 2017
retest this please |
| val locationPath = new Path(inputPathStr) | ||
| val fs = locationPath.getFileSystem(sparkSession.sessionState.newHadoopConf()) | ||
| // if the table location is not exists, return an empty RDD |
SparkQA
commented
Feb 21, 2017
Test build #73193 has finished for PR 16910 at commit
|
SparkQA
commented
Feb 21, 2017
Test build #73194 has finished for PR 16910 at commit
|
SparkQA
commented
Feb 21, 2017
Test build #73196 has finished for PR 16910 at commit
|
windpiger
commented
Feb 22, 2017
@gatorsmile I have fixed the review above~ |
| HadoopTableReader.fillObject(iter, deserializer, attrsWithIndex, mutableRow, deserializer) | ||
| } | ||
| val locationPath = new Path(inputPathStr) | ||
| val fs = locationPath.getFileSystem(sparkSession.sessionState.newHadoopConf()) |
There was a problem hiding this comment.
How about replacing sparkSession.sessionState.newHadoopConf() by broadcastedHadoopConf.value.value?
| |PARTITIONED BY(a, b) | ||
| |LOCATION "file:${dir.getCanonicalPath}" | ||
| """.stripMargin) | ||
| val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("t")) |
| val newDirFile = new File(dir, "x") | ||
| spark.sql(s"ALTER TABLE t PARTITION(a=1, b=2) SET LOCATION " + | ||
| s"'${newDirFile.getAbsolutePath}'") |
There was a problem hiding this comment.
101 characters...
let me modify some code.
There was a problem hiding this comment.
e...is't it 100? let me test it...
I have modify some code to make it moer clear
| val newDirFile = new File(dir, "x") | ||
| spark.sql(s"ALTER TABLE t PARTITION(a=1, b=2) SET LOCATION " + | ||
| s"'${newDirFile.getAbsolutePath}'") |
gatorsmile
commented
Feb 22, 2017
LGTM except a few minor comments. |
SparkQA
commented
Feb 22, 2017
Test build #73266 has started for PR 16910 at commit |
windpiger
commented
Feb 22, 2017
retest this please |
windpiger
commented
Mar 1, 2017
retest this please |
SparkQA
commented
Mar 1, 2017
Test build #73657 has finished for PR 16910 at commit
|
SparkQA
commented
Mar 1, 2017
Test build #73661 has finished for PR 16910 at commit
|
SparkQA
commented
Mar 1, 2017
Test build #73663 has finished for PR 16910 at commit
|
SparkQA
commented
Mar 1, 2017
Test build #73666 has finished for PR 16910 at commit
|
| val fs = dirPath.getFileSystem(spark.sessionState.newHadoopConf()) | ||
| assert(new Path(table.location) == fs.makeQualified(dirPath)) | ||
| val tableLocFile = new File(table.location.stripPrefix("file:")) |
There was a problem hiding this comment.
new File(new URI(table.location))? please avoid .stripPrefix("file:") which looks very hacky.
| checkAnswer(spark.table("t"), Row("c", 1) :: Nil) | ||
| val newDirFile = new File(dir, "x") | ||
| val newDirPath = newDirFile.getAbsolutePath.stripSuffix("/") |
There was a problem hiding this comment.
.stripSuffix("/") is it needed?
SparkQA
commented
Mar 1, 2017
Test build #73677 has finished for PR 16910 at commit
|
cloud-fan
commented
Mar 2, 2017
can you resolve the conflict? |
windpiger
commented
Mar 2, 2017
ok, do it now ~ yesterday is ok... |
SparkQA
commented
Mar 2, 2017
Test build #73735 has started for PR 16910 at commit |
| s""" | ||
| |CREATE TABLE t(a string, b int) | ||
| |USING hive | ||
| |LOCATION '$dir' |
There was a problem hiding this comment.
can we just call dir.delete before creating this table?
There was a problem hiding this comment.
@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.
does hive have the same behavior?
There was a problem hiding this comment.
yes, I test it in Hive
create table test(a string) location 'hdfs:/xx';
then hdfs:/xx will be created
There was a problem hiding this comment.
seems the InMemoryCatalog doesn't do this, you can send a new PR to fix it.
windpiger
commented
Mar 2, 2017
retest this please |
SparkQA
commented
Mar 2, 2017
Test build #73747 has finished for PR 16910 at commit
|
SparkQA
commented
Mar 3, 2017
Test build #73829 has started for PR 16910 at commit |
windpiger
commented
Mar 3, 2017
retest this please |
SparkQA
commented
Mar 3, 2017
Test build #73831 has finished for PR 16910 at commit
|
| spark.sql(s"ALTER TABLE t PARTITION(a=1, b=2) SET LOCATION '$newDirPath'") | ||
| assert(!newDirFile.exists()) | ||
| // select from a partition which location has changed to a not existed location | ||
| withSQLConf(SQLConf.HIVE_VERIFY_PARTITION_PATH.key -> "true") { |
There was a problem hiding this comment.
if we don't set it,it will throw an exception,if we set it,it will check if the partition path exists,and will not throw exception just return emptyrdd even if path not existed
There was a problem hiding this comment.
is this expected? I think hive will always return empty result right?
There was a problem hiding this comment.
BTW this conf will be removed soon, as it has bugs.
There was a problem hiding this comment.
ok~thanks~ then here we also need to modify something?
There was a problem hiding this comment.
Yes, hive return empty , if there is a bug here(could you describe what the bug is?), we can remove the conf ,and always return result?
gatorsmile
commented
Oct 28, 2017
Should we just close it now? |
SparkQA
commented
May 31, 2018
Test build #91357 has finished for PR 16910 at commit
|
Closesapache#17422Closesapache#17619Closesapache#18034Closesapache#18229Closesapache#18268Closesapache#17973Closesapache#18125Closesapache#18918Closesapache#19274Closesapache#19456Closesapache#19510Closesapache#19420Closesapache#20090Closesapache#20177Closesapache#20304Closesapache#20319Closesapache#20543Closesapache#20437Closesapache#21261Closesapache#21726Closesapache#14653Closesapache#13143Closesapache#17894Closesapache#19758Closesapache#12951Closesapache#17092Closesapache#21240Closesapache#16910Closesapache#12904Closesapache#21731Closesapache#21095 Added: Closesapache#19233Closesapache#20100Closesapache#21453Closesapache#21455Closesapache#18477 Added: Closesapache#21812Closesapache#21787 Author: hyukjinkwon <gurwls223@apache.org> Closesapache#21781 from HyukjinKwon/closing-prs.
What changes were proposed in this pull request?
This PR is a folllowup work from SPARK-19329 - PR(#16672), which has unify the action when we reading from or writing to a datasource table with a non pre-existing locaiton, so here we should also unify the hive serde tables.
That is :
Currently when we select from a hive serde table which has a non pre-existing location will throw an exception:
How was this patch tested?
unit tests added