You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kh...@apache.org on 2014/09/03 00:29:43 UTC
svn commit: r1622146 - in
/hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig:
HCatLoader.java PigHCatUtil.java
Author: khorgath
Date: Tue Sep 2 22:29:43 2014
New Revision: 1622146
URL: http://svn.apache.org/r1622146
Log:
HIVE-7901 : CLONE - 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/hive/hcatalog/pig/HCatLoader.java
hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/PigHCatUtil.java
Modified: hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/HCatLoader.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/HCatLoader.java?rev=1622146&r1=1622145&r2=1622146&view=diff
==============================================================================
--- hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/HCatLoader.java (original)
+++ hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/HCatLoader.java Tue Sep 2 22:29:43 2014
@@ -199,7 +199,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++) {
@@ -215,7 +216,11 @@ public class HCatLoader extends HCatBase
Table table = phutil.getTable(location,
hcatServerUri != null ? hcatServerUri : PigHCatUtil.getHCatServerUri(job),
- PigHCatUtil.getHCatServerPrincipal(job));
+ PigHCatUtil.getHCatServerPrincipal(job),
+
+ // Pass job to initialize metastore conf overrides for embedded metastore case
+ // (hive.metastore.uris = "").
+ job);
HCatSchema hcatTableSchema = HCatUtil.getTableSchemaWithPtnCols(table);
try {
PigHCatUtil.validateHCatTableSchemaFollowsPigRules(hcatTableSchema);
Modified: hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/PigHCatUtil.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/PigHCatUtil.java?rev=1622146&r1=1622145&r2=1622146&view=diff
==============================================================================
--- hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/PigHCatUtil.java (original)
+++ hive/trunk/hcatalog/hcatalog-pig-adapter/src/main/java/org/apache/hive/hcatalog/pig/PigHCatUtil.java Tue Sep 2 22:29:43 2014
@@ -142,8 +142,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.setVar(HiveConf.ConfVars.METASTOREURIS, serverUri.trim());
@@ -178,7 +186,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) {
@@ -191,7 +205,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