Search in sources :

Example 6 with PartitionWithoutSD

use of org.apache.hadoop.hive.metastore.api.PartitionWithoutSD in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDEmptyLocation.

@Test(expected = MetaException.class)
public void testAddPartitionSpecWithSharedSDEmptyLocation() throws Exception {
    createTable();
    PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0);
    partition.setRelativePath("year2002");
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(""));
    client.add_partitions_pspec(partitionSpecProxy);
}
Also used : PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 7 with PartitionWithoutSD

use of org.apache.hadoop.hive.metastore.api.PartitionWithoutSD in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDNoValue.

@Test
public void testAddPartitionSpecWithSharedSDNoValue() throws Exception {
    Table table = createTable();
    PartitionWithoutSD partition = new PartitionWithoutSD();
    partition.setRelativePath("addpartspectest");
    String location = table.getSd().getLocation() + "/nullValueTest/";
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location));
    try {
        client.add_partitions_pspec(partitionSpecProxy);
        Assert.fail("Exception should have been thrown.");
    } catch (NullPointerException | TTransportException e) {
    // TODO: NPE should not be thrown.
    }
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) TTransportException(org.apache.thrift.transport.TTransportException) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 8 with PartitionWithoutSD

use of org.apache.hadoop.hive.metastore.api.PartitionWithoutSD in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDChangeRootPath.

@Test
public void testAddPartitionSpecWithSharedSDChangeRootPath() throws Exception {
    Table table = createTable();
    String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/";
    String rootPath1 = table.getSd().getLocation() + "/someotherpath/";
    PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2014"), 0);
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(rootPath));
    partitionSpecProxy.setRootLocation(rootPath1);
    client.add_partitions_pspec(partitionSpecProxy);
    Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2014"));
    Assert.assertEquals(rootPath1 + "partwithoutsd0", resultPart.getSd().getLocation());
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) Table(org.apache.hadoop.hive.metastore.api.Table) PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 9 with PartitionWithoutSD

use of org.apache.hadoop.hive.metastore.api.PartitionWithoutSD in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSD.

@Test
public void testAddPartitionSpecWithSharedSD() throws Exception {
    Table table = createTable();
    PartitionWithoutSD partition1 = buildPartitionWithoutSD(Lists.newArrayList("2013"), 1);
    PartitionWithoutSD partition2 = buildPartitionWithoutSD(Lists.newArrayList("2014"), 2);
    PartitionWithoutSD partition3 = buildPartitionWithoutSD(Lists.newArrayList("2012"), 3);
    List<PartitionWithoutSD> partitions = Lists.newArrayList(partition1, partition2, partition3);
    String location = table.getSd().getLocation() + "/sharedSDTest/";
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(partitions, buildSD(location));
    client.add_partitions_pspec(partitionSpecProxy);
    verifyPartitionSharedSD(table, "year=2013", Lists.newArrayList("2013"), 1);
    verifyPartitionSharedSD(table, "year=2014", Lists.newArrayList("2014"), 2);
    verifyPartitionSharedSD(table, "year=2012", Lists.newArrayList("2012"), 3);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 10 with PartitionWithoutSD

use of org.apache.hadoop.hive.metastore.api.PartitionWithoutSD in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDNullSd.

@Test
public void testAddPartitionSpecWithSharedSDNullSd() throws Exception {
    createTable();
    PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0);
    StorageDescriptor sd = null;
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), sd);
    try {
        client.add_partitions_pspec(partitionSpecProxy);
        Assert.fail("Exception should have been thrown.");
    } catch (NullPointerException | TTransportException e) {
    // TODO: NPE should not be thrown.
    }
}
Also used : PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor) TTransportException(org.apache.thrift.transport.TTransportException) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

PartitionWithoutSD (org.apache.hadoop.hive.metastore.api.PartitionWithoutSD)15 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)14 PartitionSpecProxy (org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy)14 Test (org.junit.Test)14 Table (org.apache.hadoop.hive.metastore.api.Table)9 Partition (org.apache.hadoop.hive.metastore.api.Partition)7 Path (org.apache.hadoop.fs.Path)2 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)2 TTransportException (org.apache.thrift.transport.TTransportException)2 HashMap (java.util.HashMap)1 PartitionListComposingSpec (org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec)1 PartitionSpec (org.apache.hadoop.hive.metastore.api.PartitionSpec)1 PartitionSpecWithSharedSD (org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD)1