use of org.apache.hive.hcatalog.common.HCatException in project hive by apache.
the class MetadataJSONSerializer method deserializeTable.
@Override
public HCatTable deserializeTable(String hcatTableStringRep) throws HCatException {
try {
Table table = new Table();
new TDeserializer(new TJSONProtocol.Factory()).deserialize(table, hcatTableStringRep, "UTF-8");
return new HCatTable(table);
} catch (TException exception) {
if (LOG.isDebugEnabled())
LOG.debug("Could not de-serialize from: " + hcatTableStringRep);
throw new HCatException("Could not de-serialize HCatTable.", exception);
}
}
use of org.apache.hive.hcatalog.common.HCatException in project hive by apache.
the class MetadataJSONSerializer method serializePartitionSpec.
@Override
@InterfaceAudience.LimitedPrivate({ "Hive" })
@InterfaceStability.Evolving
public List<String> serializePartitionSpec(HCatPartitionSpec hcatPartitionSpec) throws HCatException {
try {
List<String> stringReps = new ArrayList<String>();
TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
for (PartitionSpec partitionSpec : hcatPartitionSpec.partitionSpecProxy.toPartitionSpec()) {
stringReps.add(serializer.toString(partitionSpec, "UTF-8"));
}
return stringReps;
} catch (TException serializationException) {
throw new HCatException("Failed to serialize!", serializationException);
}
}
use of org.apache.hive.hcatalog.common.HCatException in project hive by apache.
the class MetadataJSONSerializer method deserializePartition.
@Override
public HCatPartition deserializePartition(String hcatPartitionStringRep) throws HCatException {
try {
Partition partition = new Partition();
new TDeserializer(new TJSONProtocol.Factory()).deserialize(partition, hcatPartitionStringRep, "UTF-8");
return new HCatPartition(null, partition);
} catch (TException exception) {
if (LOG.isDebugEnabled())
LOG.debug("Could not de-serialize partition from: " + hcatPartitionStringRep);
throw new HCatException("Could not de-serialize HCatPartition.", exception);
}
}
use of org.apache.hive.hcatalog.common.HCatException in project hive by apache.
the class HCatClient method create.
/**
* Creates an instance of HCatClient.
*
* @param conf An instance of configuration.
* @return An instance of HCatClient.
* @throws HCatException
*/
public static HCatClient create(Configuration conf) throws HCatException {
HCatClient client = null;
String className = conf.get(HCAT_CLIENT_IMPL_CLASS, HCatClientHMSImpl.class.getName());
try {
Class<? extends HCatClient> clientClass = Class.forName(className, true, Utilities.getSessionSpecifiedClassLoader()).asSubclass(HCatClient.class);
client = (HCatClient) clientClass.newInstance();
} catch (ClassNotFoundException e) {
throw new HCatException("ClassNotFoundException while creating client class.", e);
} catch (InstantiationException e) {
throw new HCatException("InstantiationException while creating client class.", e);
} catch (IllegalAccessException e) {
throw new HCatException("IllegalAccessException while creating client class.", e);
}
if (client != null) {
client.initialize(conf);
}
return client;
}
use of org.apache.hive.hcatalog.common.HCatException in project hive by apache.
the class HCatClientHMSImpl method dropPartitions.
@Override
public void dropPartitions(String dbName, String tableName, Map<String, String> partitionSpec, boolean ifExists, boolean deleteData) throws HCatException {
LOG.info("HCatClient dropPartitions(db=" + dbName + ",table=" + tableName + ", partitionSpec: [" + partitionSpec + "]).");
try {
dbName = checkDB(dbName);
Table table = hmsClient.getTable(dbName, tableName);
if (hiveConfig.getBoolVar(HiveConf.ConfVars.METASTORE_CLIENT_DROP_PARTITIONS_WITH_EXPRESSIONS)) {
try {
dropPartitionsUsingExpressions(table, partitionSpec, ifExists, deleteData);
} catch (SemanticException parseFailure) {
LOG.warn("Could not push down partition-specification to back-end, for dropPartitions(). Resorting to iteration.", parseFailure);
dropPartitionsIteratively(dbName, tableName, partitionSpec, ifExists, deleteData);
}
} else {
// Not using expressions.
dropPartitionsIteratively(dbName, tableName, partitionSpec, ifExists, deleteData);
}
} catch (NoSuchObjectException e) {
throw new ObjectNotFoundException("NoSuchObjectException while dropping partition. " + "Either db(" + dbName + ") or table(" + tableName + ") missing.", e);
} catch (MetaException e) {
throw new HCatException("MetaException while dropping partition.", e);
} catch (TException e) {
throw new ConnectionFailureException("TException while dropping partition.", e);
}
}
Aggregations