diff --git itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index f79dbac573..9b102f2a36 100644 --- itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -96,6 +96,7 @@ import org.apache.hadoop.hive.common.io.SortPrintStream; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; import org.apache.hive.druid.MiniDruidCluster; import org.apache.hadoop.hive.llap.LlapItUtils; import org.apache.hadoop.hive.llap.daemon.MiniLlapCluster; @@ -555,6 +556,7 @@ public QTestUtil(String outDir, String logDir, MiniClusterType clusterType, // HIVE-14443 move this fall-back logic to CliConfigs if (confDir != null && !confDir.isEmpty()) { HiveConf.setHiveSiteLocation(new URL("file://"+ new File(confDir).toURI().getPath() + "/hive-site.xml")); + MetastoreConf.setHiveSiteLocation(HiveConf.getHiveSiteLocation()); System.out.println("Setting hive-site: "+HiveConf.getHiveSiteLocation()); } diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java index 2e43dc85ea..00f3c8d84e 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java @@ -1032,6 +1032,10 @@ private MetastoreConf() { throw new RuntimeException("You should never be creating one of these!"); } + public static void setHiveSiteLocation(URL location) { + hiveSiteURL = location; + } + public static Configuration newMetastoreConf() { Configuration conf = new Configuration(); @@ -1047,7 +1051,15 @@ public static Configuration newMetastoreConf() { // Add in hive-site.xml. We add this first so that it gets overridden by the new metastore // specific files if they exist. - hiveSiteURL = findConfigFile(classLoader, "hive-site.xml"); + if(hiveSiteURL == null) { + /* + * this 'if' is pretty lame - QTestUtil.QTestUtil() uses hiveSiteURL to load a specific + * hive-site.xml from data/conf/ so this makes it follow the same logic - otherwise + * HiveConf and MetastoreConf may load different hive-site.xml ( For example, + * HiveConf uses data/conf/spark/hive-site.xml and MetastoreConf data/conf/hive-site.xml) + */ + hiveSiteURL = findConfigFile(classLoader, "hive-site.xml"); + } if (hiveSiteURL != null) conf.addResource(hiveSiteURL); // Now add hivemetastore-site.xml. Again we add this before our own config files so that the