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

[SPARK-37561][SQL] Avoid loading all functions when obtaining hive's DelegationToken #34822

Closed
wants to merge 7 commits into from

Conversation

cxzl25
Copy link
Contributor

@cxzl25 cxzl25 commented Dec 6, 2021

What changes were proposed in this pull request?

Use Hive.getWithoutRegisterFns instead of Hive.get to avoid loading all permanent functions from the hive meta store.

Why are the changes needed?

At present, when obtaining the delegationToken of hive, all functions will be loaded.
This is unnecessary, it takes time to load the function, and it also increases the burden on the hive meta store.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

manual test

@github-actions github-actions bot added the SQL label Dec 6, 2021
@cxzl25
Copy link
Contributor Author

cxzl25 commented Dec 6, 2021

getDelegationToken_load_functions

@cxzl25 cxzl25 changed the title [SPARK-37561][Hive] Avoid loading all functions when obtaining hive's DelegationToken [SPARK-37561][SQL] Avoid loading all functions when obtaining hive's DelegationToken Dec 6, 2021
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@HyukjinKwon
Copy link
Member

cc @sunchao

val hive = Hive.get(conf, classOf[HiveConf])
val hive = conf match {
case hiveConf: HiveConf =>
Hive.getWithoutRegisterFns(hiveConf)
Copy link
Member

@HyukjinKwon HyukjinKwon Dec 7, 2021

Choose a reason for hiding this comment

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

we will have to mimic

try {
classOf[Hive].getMethod("getWithoutRegisterFns", classOf[HiveConf])
.invoke(null, conf).asInstanceOf[Hive]
} catch {
// SPARK-37069: not all Hive versions have the above method (e.g., Hive 2.3.9 has it but
// 2.3.8 don't), therefore here we fallback when encountering the exception.
case _: NoSuchMethodException =>
Hive.get(conf)
approach to allow other versions of hive when building. cc @AngersZhuuuu FYI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I thought at first that code that has nothing to do with HiveClientImpl does not need to be compatible with lower versions. I also use reflection to solve compatibility problems.

val hive = Hive.get(conf, classOf[HiveConf])
val hive = conf match {
case hiveConf: HiveConf =>
try {
Copy link
Member

Choose a reason for hiding this comment

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

can we reduce the code duplication by moving HiveClientImpl.getHive to its companion object and then call the method here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


/**
* Initialize Hive through Configuration.
* first try to use getWithoutRegisterFns to initialize to avoid loading all functions,
Copy link
Member

Choose a reason for hiding this comment

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

nit: first -> First

Hive.get(hiveConf)
}
case _ =>
Hive.get(conf, classOf[HiveConf])
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can also call getWithoutRegisterFns for this path? by first converting the Configuration to a HiveConf.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@sunchao sunchao left a comment

Choose a reason for hiding this comment

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

LGTM (pending CI).

@sunchao sunchao closed this in 5edd959 Dec 9, 2021
@sunchao
Copy link
Member

sunchao commented Dec 9, 2021

Merged, thanks!

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

Successfully merging this pull request may close these issues.

4 participants