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

    https://github.com/apache/spark/pull/12220#discussion_r59308833
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala 
---
    @@ -367,9 +367,27 @@ private[hive] class HiveClientImpl(
       override def dropPartitions(
           db: String,
           table: String,
    -      specs: Seq[ExternalCatalog.TablePartitionSpec]): Unit = 
withHiveState {
    +      specs: Seq[ExternalCatalog.TablePartitionSpec],
    +      ignoreIfNotExists: Boolean,
    +      purge: Boolean): Unit = withHiveState {
         // TODO: figure out how to drop multiple partitions in one call
    -    specs.foreach { s => client.dropPartition(db, table, 
s.values.toList.asJava, true) }
    +    val hiveTable = client.getTable(db, table, true /* throw exception */)
    +    specs.foreach { s =>
    +      // The provided spec here can be a partial spec, i.e. it will match 
all partitions
    +      // whose specs are supersets of this partial spec. E.g. If a table 
has partitions
    +      // (b='1', c='1') and (b='1', c='2'), a partial spec of (b='1') will 
match both.
    +      val matchingParts = client.getPartitions(hiveTable, s.asJava).asScala
    +      if (matchingParts.isEmpty && !ignoreIfNotExists) {
    +        throw new AnalysisException(
    +          s"partition to drop '$s' does not exist in table '$table' 
database '$db'")
    +      }
    +      matchingParts.foreach { hivePartition =>
    +        val dropOptions = new PartitionDropOptions
    +        dropOptions.ifExists = ignoreIfNotExists
    +        dropOptions.purgeData = purge
    +        client.dropPartition(db, table, hivePartition.getValues, 
dropOptions)
    --- End diff --
    
    removed


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

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

Reply via email to