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 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);
}
}
use of org.apache.hive.hcatalog.common.HCatException in project hive by apache.
the class HCatClientHMSImpl method listPartitionsByFilter.
@Override
public List<HCatPartition> listPartitionsByFilter(String dbName, String tblName, String filter) throws HCatException {
List<HCatPartition> hcatPtns = new ArrayList<HCatPartition>();
try {
HCatTable table = getTable(dbName, tblName);
List<Partition> hivePtns = hmsClient.listPartitionsByFilter(table.getDbName(), table.getTableName(), filter, (short) -1);
for (Partition ptn : hivePtns) {
hcatPtns.add(new HCatPartition(table, ptn));
}
} catch (MetaException e) {
throw new HCatException("MetaException while fetching partitions.", e);
} catch (NoSuchObjectException e) {
throw new ObjectNotFoundException("NoSuchObjectException while fetching partitions.", e);
} catch (TException e) {
throw new ConnectionFailureException("TException while fetching partitions.", e);
}
return hcatPtns;
}
Aggregations