You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by xu...@apache.org on 2015/03/12 13:59:42 UTC
svn commit: r1666173 [7/7] - in /hive/trunk: metastore/if/
metastore/src/gen/thrift/gen-cpp/
metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/
metastore/src/gen/thrift/gen-php/metastore/
metastore/src/gen/thrift/gen-py/hive_me...
Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java Thu Mar 12 12:59:41 2015
@@ -294,6 +294,11 @@ public class HiveMetaStoreClient impleme
}
@Override
+ public void setHiveAddedJars(String addedJars) {
+ HiveConf.setVar(conf, ConfVars.HIVEADDEDJARS, addedJars);
+ }
+
+ @Override
public void reconnect() throws MetaException {
if (localMetaStore) {
// For direct DB connections we don't yet support reestablishing connections.
@@ -1480,7 +1485,15 @@ public class HiveMetaStoreClient impleme
public List<FieldSchema> getSchema(String db, String tableName)
throws MetaException, TException, UnknownTableException,
UnknownDBException {
- return deepCopyFieldSchemas(client.get_schema(db, tableName));
+ EnvironmentContext envCxt = null;
+ String addedJars = conf.getVar(ConfVars.HIVEADDEDJARS);
+ if(org.apache.commons.lang.StringUtils.isNotBlank(addedJars)) {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put("hive.added.jars.path", addedJars);
+ envCxt = new EnvironmentContext(props);
+ }
+
+ return deepCopyFieldSchemas(client.get_schema_with_environment_context(db, tableName, envCxt));
}
@Override
Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java Thu Mar 12 12:59:41 2015
@@ -95,6 +95,12 @@ public interface IMetaStoreClient {
boolean isCompatibleWith(HiveConf conf);
/**
+ * Set added jars path info to MetaStoreClient.
+ * @param addedJars the hive.added.jars.path. It is qualified paths separated by commas.
+ */
+ void setHiveAddedJars(String addedJars);
+
+ /**
* Tries to reconnect this MetaStoreClient to the MetaStore.
*/
void reconnect() throws MetaException;
Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java Thu Mar 12 12:59:41 2015
@@ -25,7 +25,10 @@ import java.lang.reflect.InvocationTarge
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -39,6 +42,7 @@ import java.util.regex.Pattern;
import com.google.common.base.Predicates;
import com.google.common.collect.Maps;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -1653,4 +1657,52 @@ public class MetaStoreUtils {
}
}
+
+ /**
+ * Create a URL from a string representing a path to a local file.
+ * The path string can be just a path, or can start with file:/, file:///
+ * @param onestr path string
+ * @return
+ */
+ private static URL urlFromPathString(String onestr) {
+ URL oneurl = null;
+ try {
+ if (StringUtils.indexOf(onestr, "file:/") == 0) {
+ oneurl = new URL(onestr);
+ } else {
+ oneurl = new File(onestr).toURL();
+ }
+ } catch (Exception err) {
+ LOG.error("Bad URL " + onestr + ", ignoring path");
+ }
+ return oneurl;
+ }
+
+ /**
+ * Add new elements to the classpath.
+ *
+ * @param newPaths
+ * Array of classpath elements
+ */
+ public static ClassLoader addToClassPath(ClassLoader cloader, String[] newPaths) throws Exception {
+ URLClassLoader loader = (URLClassLoader) cloader;
+ List<URL> curPath = Arrays.asList(loader.getURLs());
+ ArrayList<URL> newPath = new ArrayList<URL>();
+
+ // get a list with the current classpath components
+ for (URL onePath : curPath) {
+ newPath.add(onePath);
+ }
+ curPath = newPath;
+
+ for (String onestr : newPaths) {
+ URL oneurl = urlFromPathString(onestr);
+ if (oneurl != null && !curPath.contains(oneurl)) {
+ curPath.add(oneurl);
+ }
+ }
+
+ return new URLClassLoader(curPath.toArray(new URL[0]), loader);
+ }
+
}
Modified: hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java (original)
+++ hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java Thu Mar 12 12:59:41 2015
@@ -528,7 +528,7 @@ public class ThriftTestObj implements or
struct.field3 = new ArrayList<InnerStruct>(_list0.size);
for (int _i1 = 0; _i1 < _list0.size; ++_i1)
{
- InnerStruct _elem2; // optional
+ InnerStruct _elem2; // required
_elem2 = new InnerStruct();
_elem2.read(iprot);
struct.field3.add(_elem2);
@@ -636,7 +636,7 @@ public class ThriftTestObj implements or
struct.field3 = new ArrayList<InnerStruct>(_list5.size);
for (int _i6 = 0; _i6 < _list5.size; ++_i6)
{
- InnerStruct _elem7; // optional
+ InnerStruct _elem7; // required
_elem7 = new InnerStruct();
_elem7.read(iprot);
struct.field3.add(_elem7);
Modified: hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java (original)
+++ hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java Thu Mar 12 12:59:41 2015
@@ -1211,7 +1211,7 @@ public class Complex implements org.apac
struct.lint = new ArrayList<Integer>(_list18.size);
for (int _i19 = 0; _i19 < _list18.size; ++_i19)
{
- int _elem20; // optional
+ int _elem20; // required
_elem20 = iprot.readI32();
struct.lint.add(_elem20);
}
@@ -1229,7 +1229,7 @@ public class Complex implements org.apac
struct.lString = new ArrayList<String>(_list21.size);
for (int _i22 = 0; _i22 < _list21.size; ++_i22)
{
- String _elem23; // optional
+ String _elem23; // required
_elem23 = iprot.readString();
struct.lString.add(_elem23);
}
@@ -1247,7 +1247,7 @@ public class Complex implements org.apac
struct.lintString = new ArrayList<IntString>(_list24.size);
for (int _i25 = 0; _i25 < _list24.size; ++_i25)
{
- IntString _elem26; // optional
+ IntString _elem26; // required
_elem26 = new IntString();
_elem26.read(iprot);
struct.lintString.add(_elem26);
@@ -1610,7 +1610,7 @@ public class Complex implements org.apac
struct.lint = new ArrayList<Integer>(_list57.size);
for (int _i58 = 0; _i58 < _list57.size; ++_i58)
{
- int _elem59; // optional
+ int _elem59; // required
_elem59 = iprot.readI32();
struct.lint.add(_elem59);
}
@@ -1623,7 +1623,7 @@ public class Complex implements org.apac
struct.lString = new ArrayList<String>(_list60.size);
for (int _i61 = 0; _i61 < _list60.size; ++_i61)
{
- String _elem62; // optional
+ String _elem62; // required
_elem62 = iprot.readString();
struct.lString.add(_elem62);
}
@@ -1636,7 +1636,7 @@ public class Complex implements org.apac
struct.lintString = new ArrayList<IntString>(_list63.size);
for (int _i64 = 0; _i64 < _list63.size; ++_i64)
{
- IntString _elem65; // optional
+ IntString _elem65; // required
_elem65 = new IntString();
_elem65.read(iprot);
struct.lintString.add(_elem65);
Modified: hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java (original)
+++ hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java Thu Mar 12 12:59:41 2015
@@ -2280,7 +2280,7 @@ public class MegaStruct implements org.a
_val19 = new ArrayList<String>(_list20.size);
for (int _i21 = 0; _i21 < _list20.size; ++_i21)
{
- String _elem22; // optional
+ String _elem22; // required
_elem22 = iprot.readString();
_val19.add(_elem22);
}
@@ -2310,7 +2310,7 @@ public class MegaStruct implements org.a
_val26 = new ArrayList<MiniStruct>(_list27.size);
for (int _i28 = 0; _i28 < _list27.size; ++_i28)
{
- MiniStruct _elem29; // optional
+ MiniStruct _elem29; // required
_elem29 = new MiniStruct();
_elem29.read(iprot);
_val26.add(_elem29);
@@ -2333,7 +2333,7 @@ public class MegaStruct implements org.a
struct.my_stringlist = new ArrayList<String>(_list30.size);
for (int _i31 = 0; _i31 < _list30.size; ++_i31)
{
- String _elem32; // optional
+ String _elem32; // required
_elem32 = iprot.readString();
struct.my_stringlist.add(_elem32);
}
@@ -2351,7 +2351,7 @@ public class MegaStruct implements org.a
struct.my_structlist = new ArrayList<MiniStruct>(_list33.size);
for (int _i34 = 0; _i34 < _list33.size; ++_i34)
{
- MiniStruct _elem35; // optional
+ MiniStruct _elem35; // required
_elem35 = new MiniStruct();
_elem35.read(iprot);
struct.my_structlist.add(_elem35);
@@ -2370,7 +2370,7 @@ public class MegaStruct implements org.a
struct.my_enumlist = new ArrayList<MyEnum>(_list36.size);
for (int _i37 = 0; _i37 < _list36.size; ++_i37)
{
- MyEnum _elem38; // optional
+ MyEnum _elem38; // required
_elem38 = MyEnum.findByValue(iprot.readI32());
struct.my_enumlist.add(_elem38);
}
@@ -2388,7 +2388,7 @@ public class MegaStruct implements org.a
struct.my_stringset = new HashSet<String>(2*_set39.size);
for (int _i40 = 0; _i40 < _set39.size; ++_i40)
{
- String _elem41; // optional
+ String _elem41; // required
_elem41 = iprot.readString();
struct.my_stringset.add(_elem41);
}
@@ -2406,7 +2406,7 @@ public class MegaStruct implements org.a
struct.my_enumset = new HashSet<MyEnum>(2*_set42.size);
for (int _i43 = 0; _i43 < _set42.size; ++_i43)
{
- MyEnum _elem44; // optional
+ MyEnum _elem44; // required
_elem44 = MyEnum.findByValue(iprot.readI32());
struct.my_enumset.add(_elem44);
}
@@ -2424,7 +2424,7 @@ public class MegaStruct implements org.a
struct.my_structset = new HashSet<MiniStruct>(2*_set45.size);
for (int _i46 = 0; _i46 < _set45.size; ++_i46)
{
- MiniStruct _elem47; // optional
+ MiniStruct _elem47; // required
_elem47 = new MiniStruct();
_elem47.read(iprot);
struct.my_structset.add(_elem47);
@@ -3023,7 +3023,7 @@ public class MegaStruct implements org.a
_val95 = new ArrayList<String>(_list96.size);
for (int _i97 = 0; _i97 < _list96.size; ++_i97)
{
- String _elem98; // optional
+ String _elem98; // required
_elem98 = iprot.readString();
_val95.add(_elem98);
}
@@ -3047,7 +3047,7 @@ public class MegaStruct implements org.a
_val102 = new ArrayList<MiniStruct>(_list103.size);
for (int _i104 = 0; _i104 < _list103.size; ++_i104)
{
- MiniStruct _elem105; // optional
+ MiniStruct _elem105; // required
_elem105 = new MiniStruct();
_elem105.read(iprot);
_val102.add(_elem105);
@@ -3064,7 +3064,7 @@ public class MegaStruct implements org.a
struct.my_stringlist = new ArrayList<String>(_list106.size);
for (int _i107 = 0; _i107 < _list106.size; ++_i107)
{
- String _elem108; // optional
+ String _elem108; // required
_elem108 = iprot.readString();
struct.my_stringlist.add(_elem108);
}
@@ -3077,7 +3077,7 @@ public class MegaStruct implements org.a
struct.my_structlist = new ArrayList<MiniStruct>(_list109.size);
for (int _i110 = 0; _i110 < _list109.size; ++_i110)
{
- MiniStruct _elem111; // optional
+ MiniStruct _elem111; // required
_elem111 = new MiniStruct();
_elem111.read(iprot);
struct.my_structlist.add(_elem111);
@@ -3091,7 +3091,7 @@ public class MegaStruct implements org.a
struct.my_enumlist = new ArrayList<MyEnum>(_list112.size);
for (int _i113 = 0; _i113 < _list112.size; ++_i113)
{
- MyEnum _elem114; // optional
+ MyEnum _elem114; // required
_elem114 = MyEnum.findByValue(iprot.readI32());
struct.my_enumlist.add(_elem114);
}
@@ -3104,7 +3104,7 @@ public class MegaStruct implements org.a
struct.my_stringset = new HashSet<String>(2*_set115.size);
for (int _i116 = 0; _i116 < _set115.size; ++_i116)
{
- String _elem117; // optional
+ String _elem117; // required
_elem117 = iprot.readString();
struct.my_stringset.add(_elem117);
}
@@ -3117,7 +3117,7 @@ public class MegaStruct implements org.a
struct.my_enumset = new HashSet<MyEnum>(2*_set118.size);
for (int _i119 = 0; _i119 < _set118.size; ++_i119)
{
- MyEnum _elem120; // optional
+ MyEnum _elem120; // required
_elem120 = MyEnum.findByValue(iprot.readI32());
struct.my_enumset.add(_elem120);
}
@@ -3130,7 +3130,7 @@ public class MegaStruct implements org.a
struct.my_structset = new HashSet<MiniStruct>(2*_set121.size);
for (int _i122 = 0; _i122 < _set121.size; ++_i122)
{
- MiniStruct _elem123; // optional
+ MiniStruct _elem123; // required
_elem123 = new MiniStruct();
_elem123.read(iprot);
struct.my_structset.add(_elem123);
Modified: hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/PropValueUnion.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/PropValueUnion.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/PropValueUnion.java (original)
+++ hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/PropValueUnion.java Thu Mar 12 12:59:41 2015
@@ -300,7 +300,7 @@ public class PropValueUnion extends org.
lString = new ArrayList<String>(_list0.size);
for (int _i1 = 0; _i1 < _list0.size; ++_i1)
{
- String _elem2; // optional
+ String _elem2; // required
_elem2 = iprot.readString();
lString.add(_elem2);
}
@@ -423,7 +423,7 @@ public class PropValueUnion extends org.
lString = new ArrayList<String>(_list9.size);
for (int _i10 = 0; _i10 < _list9.size; ++_i10)
{
- String _elem11; // optional
+ String _elem11; // required
_elem11 = iprot.readString();
lString.add(_elem11);
}
Modified: hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/SetIntString.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/SetIntString.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/SetIntString.java (original)
+++ hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/SetIntString.java Thu Mar 12 12:59:41 2015
@@ -431,7 +431,7 @@ public class SetIntString implements org
struct.sIntString = new HashSet<IntString>(2*_set82.size);
for (int _i83 = 0; _i83 < _set82.size; ++_i83)
{
- IntString _elem84; // optional
+ IntString _elem84; // required
_elem84 = new IntString();
_elem84.read(iprot);
struct.sIntString.add(_elem84);
@@ -530,7 +530,7 @@ public class SetIntString implements org
struct.sIntString = new HashSet<IntString>(2*_set87.size);
for (int _i88 = 0; _i88 < _set87.size; ++_i88)
{
- IntString _elem89; // optional
+ IntString _elem89; // required
_elem89 = new IntString();
_elem89.read(iprot);
struct.sIntString.add(_elem89);
Modified: hive/trunk/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java Thu Mar 12 12:59:41 2015
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hive.service.cli.ColumnDescriptor;
Modified: hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java?rev=1666173&r1=1666172&r2=1666173&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java Thu Mar 12 12:59:41 2015
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hive.common.cli.HiveFileProcessor;
@@ -39,6 +40,7 @@ import org.apache.hadoop.hive.metastore.
import org.apache.hadoop.hive.metastore.api.MetaException;
import org.apache.hadoop.hive.ql.exec.FetchFormatter;
import org.apache.hadoop.hive.ql.exec.ListSinkOperator;
+import org.apache.hadoop.hive.ql.exec.Utilities;
import org.apache.hadoop.hive.ql.history.HiveHistory;
import org.apache.hadoop.hive.ql.metadata.Hive;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -498,7 +500,11 @@ public class HiveSessionImpl implements
public OperationHandle getColumns(String catalogName, String schemaName,
String tableName, String columnName) throws HiveSQLException {
acquire(true);
-
+ String addedJars = Utilities.getResourceFiles(hiveConf, SessionState.ResourceType.JAR);
+ if (StringUtils.isNotBlank(addedJars)) {
+ IMetaStoreClient metastoreClient = getSession().getMetaStoreClient();
+ metastoreClient.setHiveAddedJars(addedJars);
+ }
OperationManager operationManager = getOperationManager();
GetColumnsOperation operation = operationManager.newGetColumnsOperation(getSession(),
catalogName, schemaName, tableName, columnName);