diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index aa1c925..531c96a 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -320,6 +320,17 @@ public static Hive get(boolean doRegisterAllFns) throws HiveException { return db; } + /** + * Replace the HiveConf of the thread-local Hive instance with the specified one. + * A new Hive instance will be created if it doesn't exist yet. + * @param c + * @throws HiveException + */ + public static void setConf(HiveConf c) throws HiveException { + getInternal(c, false); + } + + public static void set(Hive hive) { hiveDB.set(hive); } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java index 70b2bc0..61bec31 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java @@ -527,7 +527,7 @@ private static void start(SessionState startSs, boolean isAsync, LogHelper conso // Hive object instance should be created with a copy of the conf object. If the conf is // shared with SessionState, other parts of the code might update the config, but // Hive.get(HiveConf) would not recognize the case when it needs refreshing - Hive.get(new HiveConf(startSs.conf)).getMSC(); + Hive.setConf(new HiveConf(startSs.conf)); UserGroupInformation sessionUGI = Utils.getUGI(); FileSystem.get(startSs.conf); @@ -553,10 +553,6 @@ private static void start(SessionState startSs, boolean isAsync, LogHelper conso } } catch (RuntimeException e) { throw e; - } catch (Hive.SchemaException e) { - RuntimeException ex = new RuntimeException(e.getMessage()); - ex.setStackTrace(new StackTraceElement[0]); - throw ex; } catch (Exception e) { // Catch-all due to some exec time dependencies on session state // that would cause ClassNoFoundException otherwise @@ -823,9 +819,9 @@ private void setAuthorizerV2Config() throws HiveException { AuthorizationMetaStoreFilterHook.class.getName()); authorizerV2.applyAuthorizationConfigPolicy(conf); - // update config in Hive thread local as well and init the metastore client + // Update config in Hive thread local as well try { - Hive.get(conf).getMSC(); + Hive.setConf(conf); } catch (Exception e) { // catch-all due to some exec time dependencies on session state // that would cause ClassNoFoundException otherwise