Search in sources :

Example 1 with PartitionListComposingSpec

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

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecBothTypeSet.

@Test
public void testAddPartitionSpecBothTypeSet() throws Exception {
    Table table = createTable();
    Partition partition = buildPartition(Lists.newArrayList("2013"), getYearPartCol(), 1);
    PartitionWithoutSD partitionWithoutSD = buildPartitionWithoutSD(Lists.newArrayList("2014"), 0);
    PartitionSpec partitionSpec = new PartitionSpec();
    partitionSpec.setDbName(DB_NAME);
    partitionSpec.setTableName(TABLE_NAME);
    PartitionListComposingSpec partitionListComposingSpec = new PartitionListComposingSpec();
    partitionListComposingSpec.setPartitions(Lists.newArrayList(partition));
    partitionSpec.setPartitionList(partitionListComposingSpec);
    PartitionSpecWithSharedSD partitionSpecWithSharedSD = new PartitionSpecWithSharedSD();
    partitionSpecWithSharedSD.setPartitions(Lists.newArrayList(partitionWithoutSD));
    partitionSpecWithSharedSD.setSd(buildSD(table.getSd().getLocation() + "/sharedSDTest/"));
    partitionSpec.setSharedSDPartitionSpec(partitionSpecWithSharedSD);
    PartitionSpecProxy partitionSpecProxy = PartitionSpecProxy.Factory.get(partitionSpec);
    client.add_partitions_pspec(partitionSpecProxy);
    List<String> partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, MAX);
    Assert.assertNotNull(partitionNames);
    Assert.assertTrue(partitionNames.size() == 1);
    Assert.assertEquals("year=2013", partitionNames.get(0));
}
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) PartitionListComposingSpec(org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec) PartitionSpecWithSharedSD(org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 2 with PartitionListComposingSpec

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

the class TestAddPartitionsFromPartSpec method buildPartitionSpec.

private PartitionSpecProxy buildPartitionSpec(String dbName, String tableName, String rootPath, List<Partition> partitions) {
    PartitionSpec partitionSpec = new PartitionSpec();
    partitionSpec.setDbName(dbName);
    partitionSpec.setRootPath(rootPath);
    partitionSpec.setTableName(tableName);
    PartitionListComposingSpec partitionListComposingSpec = new PartitionListComposingSpec();
    partitionListComposingSpec.setPartitions(partitions);
    partitionSpec.setPartitionList(partitionListComposingSpec);
    return PartitionSpecProxy.Factory.get(partitionSpec);
}
Also used : PartitionListComposingSpec(org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec)

Example 3 with PartitionListComposingSpec

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

the class TestAddPartitionsFromPartSpec method buildPartitionSpec.

private PartitionSpecProxy buildPartitionSpec(List<Partition> partitions, List<PartitionWithoutSD> partitionsWithoutSD) throws MetaException {
    List<PartitionSpec> partitionSpecs = new ArrayList<>();
    PartitionSpec partitionSpec = new PartitionSpec();
    partitionSpec.setDbName(DB_NAME);
    partitionSpec.setTableName(TABLE_NAME);
    PartitionListComposingSpec partitionListComposingSpec = new PartitionListComposingSpec();
    partitionListComposingSpec.setPartitions(partitions);
    partitionSpec.setPartitionList(partitionListComposingSpec);
    PartitionSpec partitionSpecSharedSD = new PartitionSpec();
    partitionSpecSharedSD.setDbName(DB_NAME);
    partitionSpecSharedSD.setTableName(TABLE_NAME);
    PartitionSpecWithSharedSD partitionSpecWithSharedSD = new PartitionSpecWithSharedSD();
    partitionSpecWithSharedSD.setPartitions(partitionsWithoutSD);
    partitionSpecWithSharedSD.setSd(buildSD(metaStore.getWarehouseRoot() + "/" + TABLE_NAME + "/sharedSDTest/"));
    partitionSpecSharedSD.setSharedSDPartitionSpec(partitionSpecWithSharedSD);
    partitionSpecs.add(partitionSpec);
    partitionSpecs.add(partitionSpecSharedSD);
    return PartitionSpecProxy.Factory.get(partitionSpecs);
}
Also used : ArrayList(java.util.ArrayList) PartitionListComposingSpec(org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec) PartitionSpecWithSharedSD(org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD)

Aggregations

PartitionListComposingSpec (org.apache.hadoop.hive.metastore.api.PartitionListComposingSpec)3 PartitionSpec (org.apache.hadoop.hive.metastore.api.PartitionSpec)3 PartitionSpecWithSharedSD (org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD)2 ArrayList (java.util.ArrayList)1 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)1 Partition (org.apache.hadoop.hive.metastore.api.Partition)1 PartitionWithoutSD (org.apache.hadoop.hive.metastore.api.PartitionWithoutSD)1 Table (org.apache.hadoop.hive.metastore.api.Table)1 PartitionSpecProxy (org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy)1 Test (org.junit.Test)1