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 fdc7956..c0fbacf 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 @@ -321,6 +321,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/processors/SetProcessor.java b/ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java index 9a3ba04..14a3c27 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/processors/SetProcessor.java @@ -284,7 +284,7 @@ private CommandProcessorResponse getVariable(String varname) throws Exception { } } else if (varname.indexOf(METACONF_PREFIX) == 0) { String var = varname.substring(METACONF_PREFIX.length()); - Hive hive = Hive.get(ss.getConf()); + Hive hive = Hive.get(new HiveConf(ss.getConf())); String value = hive.getMetaConf(var); if (value != null) { ss.out.println(METACONF_PREFIX + var + "=" + value); 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..4e36e5b 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(new HiveConf(conf)); } catch (Exception e) { // catch-all due to some exec time dependencies on session state // that would cause ClassNoFoundException otherwise