cloud-fan commented on a change in pull request #32530:
URL: https://github.com/apache/spark/pull/32530#discussion_r631818241



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/sources/InsertSuite.scala
##########
@@ -950,6 +951,84 @@ class InsertSuite extends DataSourceTest with 
SharedSparkSession {
       checkAnswer(spark.table("t2"), Nil)
     }
   }
+
+  test("SPARK-35106: insert overwrite with custom partition path") {
+    withTable("t") {
+      sql(
+        """
+          |create table t(i int, part1 int, part2 int) using parquet
+          |partitioned by (part1, part2)
+        """.stripMargin)
+
+      val path1 = Utils.createTempDir()
+      sql(s"alter table t add partition(part1=1, part2=1) location '$path1'")
+      sql(s"insert into t partition(part1=1, part2=1) select 1")
+      checkAnswer(spark.table("t"), Row(1, 1, 1))
+
+      sql("insert overwrite table t partition(part1=1, part2=1) select 2")
+      checkAnswer(spark.table("t"), Row(2, 1, 1))
+
+      sql("insert overwrite table t partition(part1=2, part2) select 2, 2")
+      checkAnswer(spark.table("t"), Row(2, 1, 1) :: Row(2, 2, 2) :: Nil)
+
+      sql("insert overwrite table t partition(part1=1, part2=2) select 3")
+      checkAnswer(spark.table("t"), Row(2, 1, 1) :: Row(2, 2, 2) :: Row(3, 1, 
2) :: Nil)
+
+      sql("insert overwrite table t partition(part1=1, part2) select 4, 1")
+      checkAnswer(spark.table("t"), Row(4, 1, 1) :: Row(2, 2, 2) :: Nil)
+    }
+  }
+
+  test("SPARK-35106: Throw exception when rename custom partition paths 
returns false") {
+    withSQLConf(
+      "fs.file.impl" -> 
classOf[RenameFromSparkStagingToFinalDirAlwaysTurnsFalseFilesystem].getName,
+      "fs.file.impl.disable.cache" -> "true") {
+
+      withTable("t") {
+        sql(
+          """
+            |create table t(i int, part1 int, part2 int) using parquet
+            |partitioned by (part1, part2)
+          """.stripMargin)
+
+        val path1 = Utils.createTempDir()

Review comment:
       ditto `withTempDir`




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to