spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dongjoon-hyun <...@git.apache.org>
Subject [GitHub] spark pull request #15704: [SPARK-17732][SQL] ALTER TABLE DROP PARTITION sho...
Date Fri, 11 Nov 2016 09:24:26 GMT
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15704#discussion_r87558776
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
---
    @@ -225,6 +226,102 @@ class HiveDDLSuite
         }
       }
     
    +  test("SPARK-17732: Drop partitions by filter") {
    +    withTable("sales") {
    +      sql("CREATE TABLE sales(id INT) PARTITIONED BY (country STRING, quarter STRING)")
    +
    +      for (country <- Seq("US", "CA", "KR")) {
    +        for (quarter <- 1 to 4) {
    +          sql(s"ALTER TABLE sales ADD PARTITION (country='$country', quarter='$quarter')")
    +        }
    +      }
    +
    +      sql("ALTER TABLE sales DROP PARTITION (country < 'KR', quarter > '2')")
    +      checkAnswer(sql("SHOW PARTITIONS sales"),
    +        Row("country=CA/quarter=1") ::
    +        Row("country=CA/quarter=2") ::
    +        Row("country=KR/quarter=1") ::
    +        Row("country=KR/quarter=2") ::
    +        Row("country=KR/quarter=3") ::
    +        Row("country=KR/quarter=4") ::
    +        Row("country=US/quarter=1") ::
    +        Row("country=US/quarter=2") ::
    +        Row("country=US/quarter=3") ::
    +        Row("country=US/quarter=4") :: Nil)
    +
    +      sql("ALTER TABLE sales DROP PARTITION (country < 'KR'), PARTITION (quarter <=
'1')")
    +      checkAnswer(sql("SHOW PARTITIONS sales"),
    +        Row("country=KR/quarter=2") ::
    +        Row("country=KR/quarter=3") ::
    +        Row("country=KR/quarter=4") ::
    +        Row("country=US/quarter=2") ::
    +        Row("country=US/quarter=3") ::
    +        Row("country=US/quarter=4") :: Nil)
    +
    +      sql("ALTER TABLE sales DROP PARTITION (country='KR', quarter='4')")
    +      sql("ALTER TABLE sales DROP PARTITION (country='US', quarter='3')")
    +      checkAnswer(sql("SHOW PARTITIONS sales"),
    +        Row("country=KR/quarter=2") ::
    +        Row("country=KR/quarter=3") ::
    +        Row("country=US/quarter=2") ::
    +        Row("country=US/quarter=4") :: Nil)
    +
    +      sql("ALTER TABLE sales DROP PARTITION (quarter <= 2), PARTITION (quarter >=
'4')")
    +      checkAnswer(sql("SHOW PARTITIONS sales"),
    +        Row("country=KR/quarter=3") :: Nil)
    +
    +      val m = intercept[AnalysisException] {
    +        sql("ALTER TABLE sales DROP PARTITION (quarter <= 4), PARTITION (quarter <=
'2')")
    +      }.getMessage
    +      // `PARTITION (quarter <= '2')` should raises exceptions because `PARTITION
(quarter <= 4)`
    +      // already removes all partitions.
    --- End diff --
    
    For Case 1, we had better prevent query execution. I think that is consistent with equal
only spec.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message