Skip to content

Commit 3f15ad7

Browse files
lianchengyhuai
authored andcommitted
[SPARK-11783][SQL] Fixes execution Hive client when using remote Hive metastore
When using remote Hive metastore, `hive.metastore.uris` is set to the metastore URI. However, it overrides `javax.jdo.option.ConnectionURL` unexpectedly, thus the execution Hive client connects to the actual remote Hive metastore instead of the Derby metastore created in the temporary directory. Cleaning this configuration for the execution Hive client fixes this issue. Author: Cheng Lian <[email protected]> Closes #9895 from liancheng/spark-11783.clean-remote-metastore-config. (cherry picked from commit c7f95df) Signed-off-by: Yin Huai <[email protected]>
1 parent 0155693 commit 3f15ad7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,21 @@ private[hive] object HiveContext {
736736
s"jdbc:derby:;databaseName=${localMetastore.getAbsolutePath};create=true")
737737
propMap.put("datanucleus.rdbms.datastoreAdapterClassName",
738738
"org.datanucleus.store.rdbms.adapter.DerbyAdapter")
739+
740+
// SPARK-11783: When "hive.metastore.uris" is set, the metastore connection mode will be
741+
// remote (https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin
742+
// mentions that "If hive.metastore.uris is empty local mode is assumed, remote otherwise").
743+
// Remote means that the metastore server is running in its own process.
744+
// When the mode is remote, configurations like "javax.jdo.option.ConnectionURL" will not be
745+
// used (because they are used by remote metastore server that talks to the database).
746+
// Because execution Hive should always connects to a embedded derby metastore.
747+
// We have to remove the value of hive.metastore.uris. So, the execution Hive client connects
748+
// to the actual embedded derby metastore instead of the remote metastore.
749+
// You can search HiveConf.ConfVars.METASTOREURIS in the code of HiveConf (in Hive's repo).
750+
// Then, you will find that the local metastore mode is only set to true when
751+
// hive.metastore.uris is not set.
752+
propMap.put(ConfVars.METASTOREURIS.varname, "")
753+
739754
propMap.toMap
740755
}
741756

0 commit comments

Comments
 (0)