saihemanth-cloudera commented on code in PR #6816:
URL: https://github.com/apache/hive/pull/6816#discussion_r4125133785
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/TruncateTableHandler.java:
##########
@@ -99,6 +105,22 @@ protected void beforeExecute() throws TException,
IOException {
request.getTableName(), request.getPartNames());
}
this.wh = handler.getWh();
+
+ HMSHandler hmsHandler = (HMSHandler) handler;
+ if (isPartitioned && partitions != null) {
+ this.newPartitions = new ArrayList<>(partitions.size());
+ for (Partition partition : partitions) {
+ Partition newPart = partition.deepCopy();
+ updateStatsForTruncate(newPart.getParameters(), new
EnvironmentContext());
+ hmsHandler.firePreEvent(new PreAlterPartitionEvent(dbName,
request.getTableName(), table,
+ partition.getValues(), newPart, handler));
+ newPartitions.add(newPart);
+ }
+ } else if (!isPartitioned) {
+ Table newTable = table.deepCopy();
+ updateStatsForTruncate(newTable.getParameters(), new
EnvironmentContext());
+ hmsHandler.firePreEvent(new PreAlterTableEvent(table, newTable,
handler));
Review Comment:
Same here: the pre-event sees newTable before the truncate writeId is
applied.
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/TruncateTableHandler.java:
##########
@@ -99,6 +105,22 @@ protected void beforeExecute() throws TException,
IOException {
request.getTableName(), request.getPartNames());
}
this.wh = handler.getWh();
+
+ HMSHandler hmsHandler = (HMSHandler) handler;
+ if (isPartitioned && partitions != null) {
+ this.newPartitions = new ArrayList<>(partitions.size());
+ for (Partition partition : partitions) {
+ Partition newPart = partition.deepCopy();
+ updateStatsForTruncate(newPart.getParameters(), new
EnvironmentContext());
+ hmsHandler.firePreEvent(new PreAlterPartitionEvent(dbName,
request.getTableName(), table,
+ partition.getValues(), newPart, handler));
Review Comment:
The pre-event sees newPart before writeId and DDL_TIME are added later. Can
we build the final partition before firing it?
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -1483,6 +1483,9 @@ public List<Partition> exchange_partitions(Map<String,
String> partitionSpecs,
parsedSourceDbName[DB_NAME], sourceTableName) + " not found");
}
+ firePreEvent(new PreReadTableEvent(sourceTable, this));
+ firePreEvent(new PreReadTableEvent(destinationTable, this));
Review Comment:
This runs after openTransaction() but before the try/finally. If auth denies
here, the transaction can stay open.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]