Github user tejasapatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16583#discussion_r96111096
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala 
---
    @@ -247,6 +247,16 @@ class HiveDDLSuite
         }
       }
     
    +  test("SPARK-19129: drop partition with a empty string will drop the 
whole table") {
    +    val df = spark.createDataFrame(Seq((0, "a"), (1, 
"b"))).toDF("partCol1", "name")
    +    
df.write.mode("overwrite").partitionBy("partCol1").saveAsTable("partitionedTable")
    +    val e = intercept[AnalysisException] {
    +      spark.sql("alter table partitionedTable drop partition(partCol1='')")
    --- End diff --
    
    Hive (v2.1.1) does not throw exception / error message here.
    
    ```
    ALTER TABLE partitioned_table DROP PARTITION(ds = '') ;
    OK
    Time taken: 0.152 seconds
    ```
    
    Given that (creating / inserting / querying) partitions with empty string 
is not allowed, DROP PARTITIONS going through seems inconsistent behavior to 
me. It might have made sense for supporting regexes but as per [ Hive language 
specification](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-DropPartitions),
 partition spec has to be a plain string. If there is no way to create 
partitions with empty partition column name, allowing DROP seems werid. +1 for 
throwing exception .....  unless the general consensus about hive compatibility 
is to be exact same behavior (including such weirdness).
    
    ```
    INSERT OVERWRITE TABLE partitioned_table PARTITION(ds = '') SELECT key AS 
user_id, value AS name FROM src;
    FAILED: SemanticException [Error 10006]: Line 1:49 Partition not found ''''
    
    ALTER TABLE partitioned_table ADD PARTITION(ds = '') ;
    FAILED: Execution Error, return code 1 from 
org.apache.hadoop.hive.ql.exec.DDLTask. partition spec is invalid; field ds 
does not exist or is empty
    
    DESC FORMATTED partitioned_table PARTITION(ds = '') ;
    FAILED: Execution Error, return code 1 from 
org.apache.hadoop.hive.ql.exec.DDLTask. cannot find field null from [0:user_id, 
1:name]
    
    TRUNCATE TABLE partitioned_table PARTITION(ds = '') ;
    FAILED: SemanticException [Error 10006]: Partition not found {ds=}
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to