cloud-fan commented on a change in pull request #17277:
URL: https://github.com/apache/spark/pull/17277#discussion_r532348435
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/PartitionProviderCompatibilitySuite.scala
##########
@@ -316,6 +316,28 @@ class PartitionProviderCompatibilitySuite
}
}
}
+
+ test(s"SPARK-19887 partition value is null - partition management
$enabled") {
+ withTable("test") {
+ Seq((1, "p", 1), (2, null, 2)).toDF("a", "b", "c")
+ .write.partitionBy("b", "c").saveAsTable("test")
+ checkAnswer(spark.table("test"),
+ Row(1, "p", 1) :: Row(2, null, 2) :: Nil)
+
+ Seq((3, null: String, 3)).toDF("a", "b", "c")
+ .write.mode("append").partitionBy("b", "c").saveAsTable("test")
+ checkAnswer(spark.table("test"),
+ Row(1, "p", 1) :: Row(2, null, 2) :: Row(3, null, 3) :: Nil)
+ // make sure partition pruning also works.
+ checkAnswer(spark.table("test").filter($"b".isNotNull), Row(1, "p", 1))
+
+ // empty string is an invalid partition value and we treat it as null
when read back.
Review comment:
I can't remember all the details as this PR is pretty old. This is
probably the behavior of Hive so we just followed it.
Looking at it now, I agree it's not ideal to treat invalid partition values
as null. We'd better fail earlier. Can we leave it as a known bug of v1 table
and fix it in v2?
----------------------------------------------------------------
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]