vdiravka commented on a change in pull request #1586: DRILL-6929: Exclude 
maprfs jar for default profile
URL: https://github.com/apache/drill/pull/1586#discussion_r244187396
 
 

 ##########
 File path: 
contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveStoragePlugin.java
 ##########
 @@ -217,21 +216,36 @@ public synchronized void registerSchemas(SchemaConfig 
schemaConfig, SchemaPlus p
       ruleBuilder.add(ConvertHiveParquetScanToDrillParquetScan.INSTANCE);
     }
     if 
(options.getBoolean(ExecConstants.HIVE_OPTIMIZE_MAPRDB_JSON_SCAN_WITH_NATIVE_READER))
 {
-      ruleBuilder.add(ConvertHiveMapRDBJsonScanToDrillMapRDBJsonScan.INSTANCE);
+      try {
+        Class<?> hiveToDrillMapRDBJsonRuleClass =
+            
Class.forName("org.apache.drill.exec.planner.sql.logical.ConvertHiveMapRDBJsonScanToDrillMapRDBJsonScan");
+        ruleBuilder.add((StoragePluginOptimizerRule) 
hiveToDrillMapRDBJsonRuleClass.getField("INSTANCE").get(null));
+      } catch (ReflectiveOperationException e) {
+        logger.warn("Current Drill build is not designed for working with Hive 
MapR-DB tables. " +
+            "Please disable {} option", 
ExecConstants.HIVE_OPTIMIZE_MAPRDB_JSON_SCAN_WITH_NATIVE_READER);
+      }
     }
     return ruleBuilder.build();
   }
 
   @Override
   public FormatPlugin getFormatPlugin(FormatPluginConfig formatConfig) {
     //  TODO: implement formatCreator similar to FileSystemPlugin 
formatCreator. DRILL-6621
-    if (formatConfig instanceof MapRDBFormatPluginConfig) {
-      try {
-        return new MapRDBFormatPlugin(HIVE_MAPRDB_FORMAT_PLUGIN_NAME, context, 
hiveConf, config,
-            (MapRDBFormatPluginConfig) formatConfig);
-      } catch (IOException e) {
-        throw new DrillRuntimeException("The error is occurred while 
connecting to MapR-DB", e);
+    try {
+      Class<?> mapRDBFormatPluginConfigClass =
+          
Class.forName("org.apache.drill.exec.store.mapr.db.MapRDBFormatPluginConfig");
+      Class<?> mapRDBFormatPluginClass =
+          
Class.forName("org.apache.drill.exec.store.mapr.db.MapRDBFormatPlugin");
+
+      if (mapRDBFormatPluginConfigClass.isInstance(formatConfig)) {
+        return (FormatPlugin) mapRDBFormatPluginClass.getConstructor(
+              new Class[]{String.class, DrillbitContext.class, 
Configuration.class,
+                  StoragePluginConfig.class, mapRDBFormatPluginConfigClass})
+          .newInstance(
+              new Object[]{HIVE_MAPRDB_FORMAT_PLUGIN_NAME, context, hiveConf, 
config, formatConfig});
       }
+    } catch (ReflectiveOperationException e) {
 
 Review comment:
   Is it possible to divide exceptions related to connection and instantiating 
mapRDBFormatPlugin?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to