Index: metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java =================================================================== --- metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java (revision 1408414) +++ metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java (working copy) @@ -125,6 +125,10 @@ assertEquals(expectedPartition, actualPartition); } + private void validateTableInAddPartition(Table expectedTable, Table actualTable) { + assertEquals(expectedTable, actualTable); + } + private void validatePartition(Partition expectedPartition, Partition actualPartition) { assertEquals(expectedPartition.getValues(), actualPartition.getValues()); assertEquals(expectedPartition.getDbName(), actualPartition.getDbName()); @@ -167,6 +171,10 @@ validatePartition(expectedPartition, actualPartition); } + private void validateTableInDropPartition(Table expectedTable, Table actualTable) { + validateTable(expectedTable, actualTable); + } + private void validateDropTable(Table expectedTable, Table actualTable) { validateTable(expectedTable, actualTable); } @@ -222,6 +230,7 @@ AddPartitionEvent partEvent = (AddPartitionEvent)(notifyList.get(listSize-1)); assert partEvent.getStatus(); validateAddPartition(part, partEvent.getPartition()); + validateTableInAddPartition(tbl, partEvent.getTable()); PreAddPartitionEvent prePartEvent = (PreAddPartitionEvent)(preNotifyList.get(listSize-1)); validateAddPartition(part, prePartEvent.getPartition()); @@ -324,6 +333,7 @@ DropPartitionEvent dropPart = (DropPartitionEvent)notifyList.get(listSize - 1); assert dropPart.getStatus(); validateDropPartition(part, dropPart.getPartition()); + validateTableInDropPartition(tbl, dropPart.getTable()); PreDropPartitionEvent preDropPart = (PreDropPartitionEvent)preNotifyList.get(listSize - 1); validateDropPartition(part, preDropPart.getPartition()); Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/DropPartitionEvent.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/events/DropPartitionEvent.java (revision 1408414) +++ metastore/src/java/org/apache/hadoop/hive/metastore/events/DropPartitionEvent.java (working copy) @@ -20,13 +20,16 @@ import org.apache.hadoop.hive.metastore.HiveMetaStore.HMSHandler; import org.apache.hadoop.hive.metastore.api.Partition; +import org.apache.hadoop.hive.metastore.api.Table; public class DropPartitionEvent extends ListenerEvent { + private final Table table; private final Partition partition; - public DropPartitionEvent (Partition partition, boolean status, HMSHandler handler) { + public DropPartitionEvent (Table table, Partition partition, boolean status, HMSHandler handler) { super (status, handler); + this.table = table; this.partition = partition; } @@ -37,4 +40,12 @@ return partition; } + + /** + * @return the table + */ + public Table getTable() { + + return table; + } } Index: metastore/src/java/org/apache/hadoop/hive/metastore/events/AddPartitionEvent.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/events/AddPartitionEvent.java (revision 1408414) +++ metastore/src/java/org/apache/hadoop/hive/metastore/events/AddPartitionEvent.java (working copy) @@ -20,13 +20,16 @@ import org.apache.hadoop.hive.metastore.HiveMetaStore.HMSHandler; import org.apache.hadoop.hive.metastore.api.Partition; +import org.apache.hadoop.hive.metastore.api.Table; public class AddPartitionEvent extends ListenerEvent { + private final Table table; private final Partition partition; - public AddPartitionEvent (Partition partition, boolean status, HMSHandler handler) { + public AddPartitionEvent (Table table, Partition partition, boolean status, HMSHandler handler) { super (status, handler); + this.table = table; this.partition = partition; } @@ -36,4 +39,11 @@ public Partition getPartition() { return partition; } -} \ No newline at end of file + + /** + * @return the table + */ + public Table getTable() { + return table; + } +} Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 1408414) +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy) @@ -1462,6 +1462,7 @@ Partition part = new Partition(); boolean success = false, madeDir = false; Path partLocation = null; + Table tbl = null; try { ms.openTransaction(); part.setDbName(dbName); @@ -1471,7 +1472,7 @@ PreAddPartitionEvent event = new PreAddPartitionEvent(part, this); firePreEvent(event); - Table tbl = ms.getTable(part.getDbName(), part.getTableName()); + tbl = ms.getTable(part.getDbName(), part.getTableName()); if (tbl == null) { throw new InvalidObjectException( "Unable to add partition because table or database do not exist"); @@ -1525,7 +1526,7 @@ for (MetaStoreEventListener listener : listeners) { AddPartitionEvent addPartitionEvent = - new AddPartitionEvent(part, success, this); + new AddPartitionEvent(tbl, part, success, this); listener.onAddPartition(addPartitionEvent); } } @@ -1658,6 +1659,7 @@ throws InvalidObjectException, AlreadyExistsException, MetaException { boolean success = false, madeDir = false; Path partLocation = null; + Table tbl = null; try { firePreEvent(new PreAddPartitionEvent(part, this)); @@ -1672,7 +1674,7 @@ if (old_part != null) { throw new AlreadyExistsException("Partition already exists:" + part); } - Table tbl = ms.getTable(part.getDbName(), part.getTableName()); + tbl = ms.getTable(part.getDbName(), part.getTableName()); if (tbl == null) { throw new InvalidObjectException( "Unable to add partition because table or database do not exist"); @@ -1750,7 +1752,7 @@ } for (MetaStoreEventListener listener : listeners) { AddPartitionEvent addPartitionEvent = - new AddPartitionEvent(part, success, this); + new AddPartitionEvent(tbl, part, success, this); addPartitionEvent.setEnvironmentContext(envContext); listener.onAddPartition(addPartitionEvent); } @@ -1883,7 +1885,7 @@ } } for (MetaStoreEventListener listener : listeners) { - listener.onDropPartition(new DropPartitionEvent(part, success, this)); + listener.onDropPartition(new DropPartitionEvent(tbl, part, success, this)); } } return true;