uros-b commented on code in PR #57994:
URL: https://github.com/apache/spark/pull/57994#discussion_r3801777895


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetPartitionDiscoverySuite.scala:
##########
@@ -1443,6 +1443,40 @@ class ParquetV2PartitionDiscoverySuite extends 
ParquetPartitionDiscoverySuite {
     assert(s"p_int=${ExternalCatalogUtils.DEFAULT_PARTITION_NAME}" === path)
   }
 
+  test("SPARK-51830: insertInto with string partition values " +
+    "when validatePartitionColumns is disabled") {
+    withTempDir { base =>
+      val legacyPartitionDir = new java.io.File(base, "p_int=partition_value")
+      legacyPartitionDir.mkdirs()
+      makeParquetFile(
+        (1 to 5).map(i => ParquetData(i, s"str$i")),
+        legacyPartitionDir)
+
+      val df = spark.read.parquet(base.getCanonicalPath)
+      df.createOrReplaceTempView("legacy_table")
+
+      withTempView("legacy_table") {
+        checkAnswer(
+          sql("SELECT * FROM legacy_table"),
+          (1 to 5).map(i => Row(i, s"str$i", "partition_value")))
+
+        val newData = Seq((6, "str6")).toDF("intField", "stringField")
+        intercept[NumberFormatException] {
+          newData.write.mode("append").insertInto("legacy_table")
+        }
+
+        withSQLConf(SQLConf.VALIDATE_PARTITION_COLUMNS.key -> "false") {
+          newData.write.mode("append").insertInto("legacy_table")
+
+          checkAnswer(
+            sql("SELECT * FROM legacy_table ORDER BY intField"),
+            (1 to 6).map(i => Row(i, s"str$i", "partition_value")))
+        }
+      }
+    }
+  }

Review Comment:
   The new tests exercise PartitioningUtils.getPathFragment in isolation but do 
not cover the end-to-end InsertIntoHadoopFsRelationCommand path that motivated 
the ticket. Neither the static-partition branch (line 200-203) nor the 
getCustomPartitionLocations loop (line 270-272) - both updated in this PR, is 
exercised by any test that creates a real table and calls insertInto with the 
config flag disabled. An integration test (e.g., in InsertSuite) that creates a 
partitioned table whose on-disk partition directory has a non-numeric string 
name, then asserts a successful insertInto with 
spark.sql.sources.validatePartitionColumns=false, is needed to guard the actual 
scenario.



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

Reply via email to