Repository: spark
Updated Branches:
  refs/heads/branch-1.6 015569341 -> 3f15ad783


[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 <l...@databricks.com>

Closes #9895 from liancheng/spark-11783.clean-remote-metastore-config.

(cherry picked from commit c7f95df5c6d8eb2e6f11cf58b704fea34326a5f2)
Signed-off-by: Yin Huai <yh...@databricks.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/3f15ad78
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/3f15ad78
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/3f15ad78

Branch: refs/heads/branch-1.6
Commit: 3f15ad783886d077b5ecf5eee1edfc2d699bb35a
Parents: 0155693
Author: Cheng Lian <l...@databricks.com>
Authored: Tue Nov 24 14:59:14 2015 -0800
Committer: Yin Huai <yh...@databricks.com>
Committed: Tue Nov 24 15:09:17 2015 -0800

----------------------------------------------------------------------
 .../org/apache/spark/sql/hive/HiveContext.scala      | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/3f15ad78/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
index c0bb5af..8a42641 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
@@ -736,6 +736,21 @@ private[hive] object HiveContext {
       
s"jdbc:derby:;databaseName=${localMetastore.getAbsolutePath};create=true")
     propMap.put("datanucleus.rdbms.datastoreAdapterClassName",
       "org.datanucleus.store.rdbms.adapter.DerbyAdapter")
+
+    // SPARK-11783: When "hive.metastore.uris" is set, the metastore 
connection mode will be
+    // remote 
(https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin
+    // mentions that "If hive.metastore.uris is empty local mode is assumed, 
remote otherwise").
+    // Remote means that the metastore server is running in its own process.
+    // When the mode is remote, configurations like 
"javax.jdo.option.ConnectionURL" will not be
+    // used (because they are used by remote metastore server that talks to 
the database).
+    // Because execution Hive should always connects to a embedded derby 
metastore.
+    // We have to remove the value of hive.metastore.uris. So, the execution 
Hive client connects
+    // to the actual embedded derby metastore instead of the remote metastore.
+    // You can search HiveConf.ConfVars.METASTOREURIS in the code of HiveConf 
(in Hive's repo).
+    // Then, you will find that the local metastore mode is only set to true 
when
+    // hive.metastore.uris is not set.
+    propMap.put(ConfVars.METASTOREURIS.varname, "")
+
     propMap.toMap
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to