Skip to content

Commit

Permalink
[SPARK-37446][SQL] Use reflection for getWithoutRegisterFns to allow …
Browse files Browse the repository at this point in the history
…different Hive versions for building

### What changes were proposed in this pull request?
Since Hive 2.3.9  start have function `getWithoutRegisterFns`, but user may use hive 2.3.8 or lower version.
Here we should use reflection to let user build with hive 2.3.8 or lower version

### Why are the changes needed?
Support build with hive version lower than 2.3.9 since many user will build spark with it 's own hive code and their own jar (they may do some optimize or. other thing in their own code). This pr make it easier to integrate and won't hurt current logic.

### Does this PR introduce _any_ user-facing change?
User can build spark with hive version lower than 2.3.9

### How was this patch tested?

build with command
```
./dev/make-distribution.sh --tgz -Pyarn -Phive -Phive-thriftserver -Dhive.version=2.3.8
```

Jars under dist
![image](https://user-images.githubusercontent.com/46485123/143162194-d505b151-f23d-4268-af19-6dfeccea4a74.png)

Closes #34690 from AngersZhuuuu/SPARK-37446.

Authored-by: Angerszhuuuu <angers.zhu@gmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
  • Loading branch information
AngersZhuuuu authored and HyukjinKwon committed Nov 25, 2021
1 parent 27eb687 commit 04671bd
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ private[hive] class HiveClientImpl(

private def getHive(conf: HiveConf): Hive = {
try {
Hive.getWithoutRegisterFns(conf)
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 _: NoSuchMethodError =>
case _: NoSuchMethodException =>
Hive.get(conf)
}
}
Expand Down

0 comments on commit 04671bd

Please sign in to comment.