Search in sources :

Example 1 with UnknownPartitionException

use of org.apache.hadoop.hive.metastore.api.UnknownPartitionException 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;
    }
}
Also used : UnknownTableException(org.apache.hadoop.hive.metastore.api.UnknownTableException) HashMap(java.util.HashMap) Driver(org.apache.hadoop.hive.ql.Driver) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) UnknownDBException(org.apache.hadoop.hive.metastore.api.UnknownDBException) UnknownTableException(org.apache.hadoop.hive.metastore.api.UnknownTableException) TException(org.apache.thrift.TException) UnknownPartitionException(org.apache.hadoop.hive.metastore.api.UnknownPartitionException) CommandNeedRetryException(org.apache.hadoop.hive.ql.CommandNeedRetryException) InvalidPartitionException(org.apache.hadoop.hive.metastore.api.InvalidPartitionException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) InvalidPartitionException(org.apache.hadoop.hive.metastore.api.InvalidPartitionException)

Aggregations

HashMap (java.util.HashMap)1 InvalidPartitionException (org.apache.hadoop.hive.metastore.api.InvalidPartitionException)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)1 UnknownDBException (org.apache.hadoop.hive.metastore.api.UnknownDBException)1 UnknownPartitionException (org.apache.hadoop.hive.metastore.api.UnknownPartitionException)1 UnknownTableException (org.apache.hadoop.hive.metastore.api.UnknownTableException)1 CommandNeedRetryException (org.apache.hadoop.hive.ql.CommandNeedRetryException)1 Driver (org.apache.hadoop.hive.ql.Driver)1 TException (org.apache.thrift.TException)1