cloud-fan commented on a change in pull request #29316:
URL: https://github.com/apache/spark/pull/29316#discussion_r488704783
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/sources/InsertSuite.scala
##########
@@ -866,6 +866,28 @@ class InsertSuite extends DataSourceTest with
SharedSparkSession {
}.getMessage
assert(message.contains("LOCAL is supported only with file: scheme"))
}
+
+ test("SPARK-32508 " +
+ "Disallow empty part col values in partition spec before static partition
writing") {
+ withTable("insertTable") {
+ sql(
+ """
+ |CREATE TABLE insertTable(i int, part1 string, part2 string) USING
PARQUET
+ |PARTITIONED BY (part1, part2)
+ """.stripMargin)
+ val msg = "Partition spec is invalid"
+ assert(intercept[AnalysisException] {
+ sql("INSERT INTO TABLE insertTable PARTITION(part1=1, part2='') SELECT
1")
+ }.getMessage.contains(msg))
+ assert(intercept[AnalysisException] {
+ sql("INSERT INTO TABLE insertTable PARTITION(part1='', part2) SELECT 1
,'' AS part2")
+ }.getMessage.contains(msg))
+
+ sql("INSERT INTO TABLE insertTable PARTITION(part1='1', part2='2')
SELECT 1")
+ sql("INSERT INTO TABLE insertTable PARTITION(part1='1', part2) SELECT 1
,'2' AS part2")
+ sql("INSERT INTO TABLE insertTable PARTITION(part1='1', part2) SELECT 1
,'' AS part2")
Review comment:
So the partition column can be empty string if it's dynamic. Shall we
convert the empty string/null in partition spec to `__HIVE_DEFAULT_PARTITION__`
before calling `listPartitions`/`loadPartition`?
----------------------------------------------------------------
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]