AngersZhuuuu commented on a change in pull request #33811:
URL: https://github.com/apache/spark/pull/33811#discussion_r695342681
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/sources/PartitionedWriteSuite.scala
##########
@@ -189,6 +189,33 @@ class PartitionedWriteSuite extends QueryTest with
SharedSparkSession {
}
}
}
+
+ test("SPARK-36563: dynamic partition overwrite can rename table path when
reasonable") {
+ withTempDir { stagingDir =>
+ withSQLConf(SQLConf.PARTITION_OVERWRITE_MODE.key ->
+ SQLConf.PartitionOverwriteMode.DYNAMIC.toString,
+ SQLConf.FILE_STAGING_DIR.key -> stagingDir.getAbsolutePath) {
+ withTempDir { d =>
+ withTable("t") {
+ sql(
+ s"""
+ | create table t(c1 int, p1 int) using parquet partitioned by
(p1)
+ | location '${d.getAbsolutePath}'
+ """.stripMargin)
+
+ val df = Seq((1, 2), (3, 4)).toDF("c1", "p1")
+ df.write
+ .partitionBy("p1")
+ .mode("overwrite")
+ .saveAsTable("t")
+ checkAnswer(sql("SELECT * FROM t"), df)
+ checkAnswer(sql("SELECT * FROM t WHERE p1 = 2"), Row(1, 2) :: Nil)
+ checkAnswer(sql("SELECT * FROM t WHERE p1 = 4"), Row(3, 4) :: Nil)
Review comment:
> Does this test case fail before your PR? IIUC, this doesn't provide a
test coverage.
Just to show in new way, it can write data as before?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]