Skip to content

Conversation

rtrivedi12
Copy link
Contributor

…ange in partition location

What changes were proposed in this pull request?

This change skips the DFS_URI authorization if there is no change in the PARTITION location in the ALTER_PARTITION event.

If the old partition and new partition Uri are the same or the old partition location is empty, then skip adding DFS_URI for authorization.

Why are the changes needed?

The LOAD DATA command invokes the ALTER_PARTITION event to update stats for the newly loaded partition. ALTER_PARTITION authorizes DFS_URI for the partition location even when the partition locations do not change. This requires the Hadoop SQL policy for DFS_URI to be defined for the partition location for LOAD DATA commands.

Does this PR introduce any user-facing change?

Yes, after this change, users will no longer need the DFS_URI policy for target table partition location.

Is the change a dependency upgrade?

No

How was this patch tested?

Manual testing

Copy link

Exception ex = null;
try {
Table table = getMS().getTable(catName, db_name, tbl_name, null);
Partition oldPartition = getMS().getPartition(catName, db_name, tbl_name, part_vals);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we fetch oldPart at L6062, can you see if you can eliminate this redundant call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this redundant call from HMSHandler.

if (StringUtils.isNotEmpty(newUri)) {
ret.add(getHivePrivilegeObjectDfsUri(newUri));
// Skip DFS_URI auth if old and new partition uri are empty or same
if (StringUtils.isNotEmpty(newUri) && StringUtils.isNotEmpty(oldUri) && !StringUtils.equalsIgnoreCase(oldUri,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need DFS_URI auth when newUri is not empty but oldUri is empty? Also consider add unit test for this change.

Copy link
Member

Choose a reason for hiding this comment

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

change the condition to StringUtils.isNotEmpty(newUri) & !StringUtils.equalsIgnoreCase(oldUri, newUri) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wecharyu @dengzhhu653 We want to skip DFS_URI auth when newUri is not empty but oldUri is empty like in case of stats update during LOAD PARTITION, it would have empty old uri and non-empty new URI.
But I see your point this condition would be anyways covered by !StringUtils.equalsIgnoreCase(oldUri, newUri).

Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite understand why not need check the newUri auth when oldUri is empty but newUri is not.

But I see your point this condition would be anyways covered by !StringUtils.equalsIgnoreCase(oldUri, newUri).

But the check would fail-fast by StringUtils.isNotEmpty(oldUri) in your current implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wecharyu I have updated the condition to StringUtils.isNotEmpty(newUri) & !StringUtils.equalsIgnoreCase(oldUri, newUri) now. And this patch proposes skipping DFS_URI authorization if there is no change in partition location. So, if new URI is non-empty and old uri is empty , ALTER PARTITION might be triggered for other HiveOperationType like ALTERPARTITION_FILEFORMAT, ALTERPARTITION_SERDEPROPERTIES which does not require DFS_URI auth.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the [email protected] list if the patch is in need of reviews.


if (StringUtils.isNotEmpty(newUri)) {
ret.add(getHivePrivilegeObjectDfsUri(newUri));
if (event.getOldPartVals() != null && event.getOldPartVals().size() > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have any changes in HMSHandler as part of this change. IIUC null is sent for oldPartition values and tmpPart is new partition here https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L6184

Copy link
Member

Choose a reason for hiding this comment

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

The oldPartition values are the same as the tmpPart values in this method

@rtrivedi12
Copy link
Contributor Author

@dengzhhu653 Thanks for the review! I have addressed review comments.

Copy link

@dengzhhu653 dengzhhu653 merged commit ba652d8 into apache:master Jul 10, 2025
6 checks passed
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.

5 participants