use of org.apache.hadoop.hive.metastore.api.InvalidPartitionException in project hive by apache.
the class ObjectStore method getPartitionStr.
private String getPartitionStr(Table tbl, Map<String, String> partName) throws InvalidPartitionException {
if (tbl.getPartitionKeysSize() != partName.size()) {
throw new InvalidPartitionException("Number of partition columns in table: " + tbl.getPartitionKeysSize() + " doesn't match with number of supplied partition values: " + partName.size());
}
final List<String> storedVals = new ArrayList<String>(tbl.getPartitionKeysSize());
for (FieldSchema partKey : tbl.getPartitionKeys()) {
String partVal = partName.get(partKey.getName());
if (null == partVal) {
throw new InvalidPartitionException("No value found for partition column: " + partKey.getName());
}
storedVals.add(partVal);
}
return join(storedVals, ',');
}
use of org.apache.hadoop.hive.metastore.api.InvalidPartitionException in project hive by apache.
the class TestMarkPartition method testMarkingPartitionSet.
public void testMarkingPartitionSet() throws CommandNeedRetryException, MetaException, TException, NoSuchObjectException, UnknownDBException, UnknownTableException, InvalidPartitionException, UnknownPartitionException, InterruptedException {
HiveMetaStoreClient msc = new HiveMetaStoreClient(hiveConf);
driver = new Driver(hiveConf);
driver.run("drop database if exists hive2215 cascade");
driver.run("create database hive2215");
driver.run("use hive2215");
driver.run("drop table if exists tmptbl");
driver.run("create table tmptbl (a string) partitioned by (b string)");
driver.run("alter table tmptbl add partition (b='2011')");
Map<String, String> kvs = new HashMap<String, String>();
kvs.put("b", "'2011'");
msc.markPartitionForEvent("hive2215", "tmptbl", kvs, PartitionEventType.LOAD_DONE);
assert msc.isPartitionMarkedForEvent("hive2215", "tmptbl", kvs, PartitionEventType.LOAD_DONE);
Thread.sleep(10000);
assert !msc.isPartitionMarkedForEvent("hive2215", "tmptbl", kvs, PartitionEventType.LOAD_DONE);
kvs.put("b", "'2012'");
assert !msc.isPartitionMarkedForEvent("hive2215", "tmptbl", kvs, PartitionEventType.LOAD_DONE);
try {
msc.markPartitionForEvent("hive2215", "tmptbl2", kvs, PartitionEventType.LOAD_DONE);
assert false;
} catch (Exception e) {
assert e instanceof UnknownTableException;
}
try {
msc.isPartitionMarkedForEvent("hive2215", "tmptbl2", kvs, PartitionEventType.LOAD_DONE);
assert false;
} catch (Exception e) {
assert e instanceof UnknownTableException;
}
kvs.put("a", "'2012'");
try {
msc.isPartitionMarkedForEvent("hive2215", "tmptbl", kvs, PartitionEventType.LOAD_DONE);
assert false;
} catch (Exception e) {
assert e instanceof InvalidPartitionException;
}
}
Aggregations