hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khorg...@apache.org
Subject svn commit: r1579806 - in /hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig: HCatLoader.java PigHCatUtil.java
Date Thu, 20 Mar 2014 22:25:45 GMT
Author: khorgath
Date: Thu Mar 20 22:25:45 2014
New Revision: 1579806

URL: http://svn.apache.org/r1579806
Log:
HIVE-6633 : pig -useHCatalog with embedded metastore fails to pass command line args to metastore
(Eric Hanson via Sushanth Sowmyan)

Modified:
    hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/HCatLoader.java
    hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/PigHCatUtil.java

Modified: hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/HCatLoader.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/HCatLoader.java?rev=1579806&r1=1579805&r2=1579806&view=diff
==============================================================================
--- hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/HCatLoader.java
(original)
+++ hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/HCatLoader.java
Thu Mar 20 22:25:45 2014
@@ -177,7 +177,8 @@ public class HCatLoader extends HCatBase
     throws IOException {
     Table table = phutil.getTable(location,
       hcatServerUri != null ? hcatServerUri : PigHCatUtil.getHCatServerUri(job),
-      PigHCatUtil.getHCatServerPrincipal(job));
+      PigHCatUtil.getHCatServerPrincipal(job),
+          job);   // Pass job to initialize metastore conf overrides
     List<FieldSchema> tablePartitionKeys = table.getPartitionKeys();
     String[] partitionKeys = new String[tablePartitionKeys.size()];
     for (int i = 0; i < tablePartitionKeys.size(); i++) {
@@ -193,7 +194,9 @@ public class HCatLoader extends HCatBase
 
     Table table = phutil.getTable(location,
       hcatServerUri != null ? hcatServerUri : PigHCatUtil.getHCatServerUri(job),
-      PigHCatUtil.getHCatServerPrincipal(job));
+      // Pass job to initialize metastore conf overrides for embedded metastore case
+      // (hive.metastore.uris = "").
+      PigHCatUtil.getHCatServerPrincipal(job), job);
     HCatSchema hcatTableSchema = HCatUtil.getTableSchemaWithPtnCols(table);
     try {
       PigHCatUtil.validateHCatTableSchemaFollowsPigRules(hcatTableSchema);

Modified: hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/PigHCatUtil.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/PigHCatUtil.java?rev=1579806&r1=1579805&r2=1579806&view=diff
==============================================================================
--- hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/PigHCatUtil.java
(original)
+++ hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hcatalog/pig/PigHCatUtil.java
Thu Mar 20 22:25:45 2014
@@ -133,8 +133,16 @@ class PigHCatUtil {
   }
 
   private static HiveMetaStoreClient getHiveMetaClient(String serverUri,
-                             String serverKerberosPrincipal, Class<?> clazz) throws
Exception {
-    HiveConf hiveConf = new HiveConf(clazz);
+                             String serverKerberosPrincipal,
+                             Class<?> clazz,
+                             Job job) throws Exception {
+
+    // The job configuration is passed in so the configuration will be cloned
+    // from the pig job configuration. This is necessary for overriding
+    // metastore configuration arguments like the metastore jdbc connection string
+    // and password, in the case of an embedded metastore, which you get when
+    // hive.metastore.uris = "".
+    HiveConf hiveConf = new HiveConf(job.getConfiguration(), clazz);
 
     if (serverUri != null) {
       hiveConf.set("hive.metastore.local", "false");
@@ -170,7 +178,13 @@ class PigHCatUtil {
     return new HCatSchema(fcols);
   }
 
-  public Table getTable(String location, String hcatServerUri, String hcatServerPrincipal)
throws IOException {
+  /*
+  * The job argument is passed so that configuration overrides can be used to initialize
+  * the metastore configuration in the special case of an embedded metastore
+  * (hive.metastore.uris = "").
+  */
+  public Table getTable(String location, String hcatServerUri, String hcatServerPrincipal,
+      Job job) throws IOException {
     Pair<String, String> loc_server = new Pair<String, String>(location, hcatServerUri);
     Table hcatTable = hcatTableCache.get(loc_server);
     if (hcatTable != null) {
@@ -183,7 +197,7 @@ class PigHCatUtil {
     Table table = null;
     HiveMetaStoreClient client = null;
     try {
-      client = getHiveMetaClient(hcatServerUri, hcatServerPrincipal, PigHCatUtil.class);
+      client = getHiveMetaClient(hcatServerUri, hcatServerPrincipal, PigHCatUtil.class, job);
       table = HCatUtil.getTable(client, dbName, tableName);
     } catch (NoSuchObjectException nsoe) {
       throw new PigException("Table not found : " + nsoe.getMessage(), PIG_EXCEPTION_CODE);
// prettier error messages to frontend



Mime
View raw message