srowen commented on a change in pull request #25928: [SPARK-29259][SQL] call
fs.exists only when necessary
URL: https://github.com/apache/spark/pull/25928#discussion_r328601912
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelationCommand.scala
##########
@@ -111,25 +109,30 @@ case class InsertIntoHadoopFsRelationCommand(
outputPath = outputPath.toString,
dynamicPartitionOverwrite = dynamicPartitionOverwrite)
- val doInsertion = (mode, pathExists) match {
- case (SaveMode.ErrorIfExists, true) =>
- throw new AnalysisException(s"path $qualifiedOutputPath already
exists.")
- case (SaveMode.Overwrite, true) =>
- if (ifPartitionNotExists && matchingPartitions.nonEmpty) {
- false
- } else if (dynamicPartitionOverwrite) {
- // For dynamic partition overwrite, do not delete partition
directories ahead.
- true
- } else {
- deleteMatchingPartitions(fs, qualifiedOutputPath,
customPartitionLocations, committer)
+ val doInsertion = if (mode == SaveMode.Append) {
Review comment:
Don't you want to do the same for Overwrite?
Also, yes, this is cleaner if you do two levels of pattern matching. Match
for Append, Overwrite, and in the other cases, check if it exists and then
match for the rest of the cases. No need for a lazy val.
EDIT: no that's wrong, nevermind. I think the current change is good.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]