cxzl25 commented on a change in pull request #34822:
URL: https://github.com/apache/spark/pull/34822#discussion_r765062107



##########
File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
##########
@@ -1287,4 +1276,26 @@ private[hive] object HiveClientImpl extends Logging {
     }
     hiveConf
   }
+
+  /**
+   * Initialize Hive through Configuration.
+   * first try to use getWithoutRegisterFns to initialize to avoid loading all 
functions,
+   * if there is no such method, fallback to Hive.get.
+   */
+  def getHive(conf: Configuration): Hive = {
+    conf match {
+      case hiveConf: HiveConf =>
+        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(hiveConf)
+        }
+      case _ =>
+        Hive.get(conf, classOf[HiveConf])

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to