rdblue commented on a change in pull request #1478:
URL: https://github.com/apache/iceberg/pull/1478#discussion_r496312063



##########
File path: 
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveMetastore.java
##########
@@ -94,8 +104,24 @@ public String getDatabasePath(String dbName) {
   private TServer newThriftServer(TServerSocket socket, HiveConf conf) throws 
Exception {
     HiveConf serverConf = new HiveConf(conf);
     serverConf.set(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname, 
"jdbc:derby:" + getDerbyPath() + ";create=true");
-    HiveMetaStore.HMSHandler baseHandler = new HiveMetaStore.HMSHandler("new 
db based metaserver", serverConf);
-    IHMSHandler handler = RetryingHMSHandler.getProxy(serverConf, baseHandler, 
false);
+
+    // create the metastore handlers based on whether we're working with Hive2 
or Hive3 dependencies
+    // we need to do this because there is a breaking API change between Hive2 
and Hive3
+    HiveMetaStore.HMSHandler baseHandler;
+    IHMSHandler handler;
+    if (MetastoreUtil.hive3PresentOnClasspath()) {
+      baseHandler = (HiveMetaStore.HMSHandler) Class
+              .forName(HiveMetaStore.HMSHandler.class.getName())
+              .getConstructor(String.class, Configuration.class)
+              .newInstance("new db based metaserver", serverConf);
+      handler = (IHMSHandler) Class
+              .forName(RetryingHMSHandler.class.getName())
+              .getDeclaredMethod("getProxy", Configuration.class, 
IHMSHandler.class, boolean.class)
+              .invoke(null, serverConf, baseHandler, false);
+    } else {
+      baseHandler = new HiveMetaStore.HMSHandler("new db based metaserver", 
serverConf);
+      handler = RetryingHMSHandler.getProxy(serverConf, baseHandler, false);
+    }

Review comment:
       This is also a good place to use the reflection helpers.




----------------------------------------------------------------
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.

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