Repository: spark
Updated Branches:
  refs/heads/master 25e271d9f -> bc37c9743


[SPARK-5821] [SQL] ParquetRelation2 CTAS should check if delete is successful

Do the same check as #4610 for ParquetRelation2.

Author: Yanbo Liang <yblia...@gmail.com>

Closes #5107 from yanboliang/spark-5821-parquet and squashes the following 
commits:

7092c8d [Yanbo Liang] ParquetRelation2 CTAS should check if delete is successful


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/bc37c974
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/bc37c974
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/bc37c974

Branch: refs/heads/master
Commit: bc37c9743e065a0c756363c7b70e88f22a6e6edd
Parents: 25e271d
Author: Yanbo Liang <yblia...@gmail.com>
Authored: Sat Mar 21 10:53:04 2015 +0800
Committer: Cheng Lian <l...@databricks.com>
Committed: Sat Mar 21 10:53:04 2015 +0800

----------------------------------------------------------------------
 .../apache/spark/sql/parquet/newParquet.scala    | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/bc37c974/sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala
index 10b8876..fbe7a41 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala
@@ -611,13 +611,22 @@ private[sql] case class ParquetRelation2(
     val destinationPath = new Path(paths.head)
 
     if (overwrite) {
-      try {
-        destinationPath.getFileSystem(conf).delete(destinationPath, true)
-      } catch {
-        case e: IOException =>
+      val fs = destinationPath.getFileSystem(conf)
+      if (fs.exists(destinationPath)) {
+        var success: Boolean = false
+        try {
+          success = fs.delete(destinationPath, true)
+        } catch {
+          case e: IOException =>
+            throw new IOException(
+              s"Unable to clear output directory ${destinationPath.toString} 
prior" +
+                s" to writing to Parquet table:\n${e.toString}")
+        }
+        if (!success) {
           throw new IOException(
             s"Unable to clear output directory ${destinationPath.toString} 
prior" +
-              s" to writing to Parquet file:\n${e.toString}")
+              s" to writing to Parquet table.")
+        }
       }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to