cloud-fan commented on a change in pull request #32530:
URL: https://github.com/apache/spark/pull/32530#discussion_r631818602
##########
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()
+ sql(s"alter table t add partition(part1=1, part2=1) location '$path1'")
+
+ val e = intercept[SparkException] {
+ sql(s"insert into t partition(part1=1, part2=1) select 1")
+ }.getCause
+ assert(e.isInstanceOf[IOException])
+ assert(e.getMessage.contains("Failed to rename"))
+ assert(e.getMessage.contains("when committing files staged for
absolute location"))
+ }
+ }
+ }
+
+ test("SPARK-35106: Throw exception when rename dynamic partition paths
returns false") {
+ withSQLConf(
+ "fs.file.impl" ->
classOf[RenameFromSparkStagingToFinalDirAlwaysTurnsFalseFilesystem].getName,
+ "fs.file.impl.disable.cache" -> "true",
+ SQLConf.PARTITION_OVERWRITE_MODE.key ->
PartitionOverwriteMode.DYNAMIC.toString,
+ SQLConf.FILE_COMMIT_PROTOCOL_CLASS.key ->
Review comment:
isn't it the default one?
--
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]