Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/12220#discussion_r59555113
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
---
@@ -367,9 +367,25 @@ private[hive] class HiveClientImpl(
override def dropPartitions(
db: String,
table: String,
- specs: Seq[ExternalCatalog.TablePartitionSpec]): Unit =
withHiveState {
+ specs: Seq[ExternalCatalog.TablePartitionSpec],
+ ignoreIfNotExists: 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
--- End diff --
I am afraid there is a bug in `getPartitions`. This function could return a
wrong result when the partitioning column names are wrong. For example, if we
pass `a='0'`, it will return all the partitions. The expected return should be
an empty set, right?
Two possible solutions:
1. get the whole list, and filter it out by ourselves. Do you want me to
write a test case and fix this issue?
2. check if the specs contains any column that is not part of table
partitioning at the beginning. @andrewor14 @yhuai
---
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]