cxzl25 commented on a change in pull request #29316:
URL: https://github.com/apache/spark/pull/29316#discussion_r486107004



##########
File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertSuite.scala
##########
@@ -847,4 +847,26 @@ class InsertSuite extends QueryTest with TestHiveSingleton 
with BeforeAndAfter
       }
     }
   }
+
+  test("SPARK-32508 " +
+    "Disallow empty part col values in partition spec before static partition 
writing") {
+    withTable("t1") {
+      spark.sql(
+        """
+          |CREATE TABLE t1 (c1 int)

Review comment:
       hive> INSERT OVERWRITE TABLE  t1 PARTITION(d='')  select 1;
   ```
   Caused by: org.apache.hadoop.hive.ql.parse.SemanticException: Line 1:61 
Partition not found ''''
           at 
org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer$tableSpec.<init>(BaseSemanticAnalyzer.java:856)
           at 
org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer$tableSpec.<init>(BaseSemanticAnalyzer.java:727)
           at 
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getMetaData(SemanticAnalyzer.java:1652)
           ... 23 more
   Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: get partition: 
Value for key d is null or empty
           at 
org.apache.hadoop.hive.ql.metadata.Hive.getPartition(Hive.java:1900)
   ```
   
   hive> INSERT OVERWRITE TABLE  t1 PARTITION(d)  select 1,'' as d;
   result:
   ```
   Loading data to table x.t1 partition (d=null)
         Time taken for load dynamic partitions : 302
        Loading partition {d=__HIVE_DEFAULT_PARTITION__}
         Time taken for adding to write entity : 1
   Partition x.t1{d=__HIVE_DEFAULT_PARTITION__} stats: [numFiles=1, numRows=1, 
totalSize=201, rawDataSize=85]
   
   ```
   
   
   




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

Reply via email to