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

[#1974] fix(hive): Hive table listPartitions reduces HMS RPC calls #1975

Merged
merged 2 commits into from
Feb 3, 2024

Conversation

cxzl25
Copy link
Contributor

@cxzl25 cxzl25 commented Feb 2, 2024

What changes were proposed in this pull request?

Use HMS's listPartitions RPC to replace the two RPC calls of listPartitionNames and getPartitionsByNames.

Why are the changes needed?

Fix: #1974

Does this PR introduce any user-facing change?

No

How was this patch tested?

exist UT

@cxzl25 cxzl25 changed the title [#1974] fix: Hive table listPartitions reduces HMS RPC calls [#1974] fix(hive): Hive table listPartitions reduces HMS RPC calls Feb 2, 2024
return IntStream.range(0, partitionNames.size())
.mapToObj(i -> fromHivePartition(partitionNames.get(i), partitions.get(i)))
List<String> partCols =
table.buildPartitionKeys().stream().map(FieldSchema::getName).collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

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

If the partition keys of the underlying Hive table were changed, table.buildPartitionKeys() will get an error result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hive table partition keys will not change unless the table is dropped and then created.

.map(
partition ->
fromHivePartition(
FileUtils.makePartName(partCols, partition.getValues()), partition))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to ensure that partCols and partition.getValues() have corresponding orders?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -41,7 +41,7 @@ public class TestHiveTableOperations extends MiniHiveMetastoreService {
private static Partition existingPartition;

@BeforeAll
private static void setup() {
public static void setup() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change the access modifier to public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When running related test UT, IDEA has a prompt, so it is modified by the way.

Here is a non-necessary modification, I can revert.

image

Copy link
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

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

LGTM. Could you please review this when you have time? @jerryshao @FANNG1 Thank you!

@FANNG1
Copy link
Contributor

FANNG1 commented Feb 3, 2024

LGTM

@jerryshao jerryshao added need backport Issues that need to backport to another branch branch-0.4 labels Feb 3, 2024
@mchades
Copy link
Contributor

mchades commented Feb 3, 2024

Thanks @cxzl25 and @FANNG1 , I'm gonna merge this pull request.

@mchades mchades merged commit 39226df into apache:main Feb 3, 2024
12 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 3, 2024
…1975)

### What changes were proposed in this pull request?
Use HMS's `listPartitions` RPC to replace the two RPC calls of
`listPartitionNames` and `getPartitionsByNames`.

### Why are the changes needed?

Fix: #1974

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
exist UT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch-0.4 need backport Issues that need to backport to another branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Hive table listPartitions reduces HMS RPC calls
4 participants