Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-28668: Hive should emit fewer events for truncate table operation #5582

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

saihemanth-cloudera
Copy link
Contributor

What changes were proposed in this pull request?

Currently, we emit twice the number of events for each table/partition for truncate operation. This patch removes this redundant events.

Why are the changes needed?

Having fewer events help external systems that consume these events to catch up with the quantum of events faster.

Does this PR introduce any user-facing change?

No.

Is the change a dependency upgrade?

No.

How was this patch tested?

Added unit test for the patch

}
alterHandler.alterPartition(ms, wh, catName, dbName, tableName, null, partition,
environmentContext, this, validWriteIds);
alterHandler.alterPartitions(ms, wh, catName, dbName, tableName, partitions, environmentContext,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we know this is a truncation op, can we just call ms.alterPartitions(catName, dbname, name, partValsList, new_parts, writeId, writeIdList) and create the event directly? same for truncating the non-partitioned table.

@@ -101,7 +101,7 @@ public void setConf(Configuration conf) {
@Override
public void alterTable(RawStore msdb, Warehouse wh, String catName, String dbname,
String name, Table newt, EnvironmentContext environmentContext,
IHMSHandler handler, String writeIdList)
IHMSHandler handler, String writeIdList, boolean isTruncateOp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding a new isTruncateOp, can we put it into the environmentContext, like environmentContext.putToProperties("__isTruncateOp__", "true");

context.dmd.getPayload());
tName = TableName.fromString(singleMsg.getTable(), null,
context.isDbNameEmpty() ? singleMsg.getDB() : context.dbName);
tblObj = singleMsg.getTableObj();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we create the tName from the tblObj?

Iterator<String> afterIterator = afterIteratorMap.values().iterator();
Map<String, String> partSpec = new LinkedHashMap<>();
for (FieldSchema fs : tblObj.getPartitionKeys()) {
partSpec.put(fs.getName(), afterIterator.next());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: afterIterator.next -> afterIteratorMap.get(fs.getName())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants