Search in sources :

Example 1 with PartitionWithoutSD

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

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDDBAndTableSetFromSpecProxy.

@Test
public void testAddPartitionSpecWithSharedSDDBAndTableSetFromSpecProxy() throws Exception {
    createTable();
    PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList(DEFAULT_YEAR_VALUE), 1);
    String location = metaStore.getWarehouseRoot() + "/" + TABLE_NAME + "/sharedSDTest/";
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location));
    partitionSpecProxy.setDbName(DB_NAME);
    partitionSpecProxy.setTableName(TABLE_NAME);
    client.add_partitions_pspec(partitionSpecProxy);
    Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList(DEFAULT_YEAR_VALUE));
    Assert.assertNotNull(resultPart);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) 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 2 with PartitionWithoutSD

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

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDNullLocation.

@Test(expected = MetaException.class)
public void testAddPartitionSpecWithSharedSDNullLocation() throws Exception {
    createTable();
    PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0);
    partition.setRelativePath("year2002");
    String location = null;
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location));
    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 3 with PartitionWithoutSD

use of org.apache.hadoop.hive.metastore.api.PartitionWithoutSD 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 4 with PartitionWithoutSD

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

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDNoRelativePath.

@Test
public void testAddPartitionSpecWithSharedSDNoRelativePath() throws Exception {
    Table table = createTable();
    PartitionWithoutSD partition1 = buildPartitionWithoutSD(Lists.newArrayList("2007"), 0);
    PartitionWithoutSD partition2 = buildPartitionWithoutSD(Lists.newArrayList("2008"), 0);
    partition1.setRelativePath(null);
    partition2.setRelativePath(null);
    String location = table.getSd().getLocation() + "/noRelativePath/";
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition1, partition2), buildSD(location));
    client.add_partitions_pspec(partitionSpecProxy);
    Partition resultPart1 = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2007"));
    Assert.assertEquals(location + "null", resultPart1.getSd().getLocation());
    Assert.assertTrue(metaStore.isPathExists(new Path(resultPart1.getSd().getLocation())));
    Partition resultPart2 = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2008"));
    Assert.assertEquals(location + "null", resultPart2.getSd().getLocation());
    Assert.assertTrue(metaStore.isPathExists(new Path(resultPart2.getSd().getLocation())));
}
Also used : Path(org.apache.hadoop.fs.Path) 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 5 with PartitionWithoutSD

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

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecPartDuplicateInSpecs.

@Test(expected = MetaException.class)
public void testAddPartitionSpecPartDuplicateInSpecs() throws Exception {
    createTable(DB_NAME, TABLE_NAME, getYearPartCol(), metaStore.getWarehouseRoot() + "/" + TABLE_NAME);
    Partition partition = buildPartition(Lists.newArrayList("2002"), getYearPartCol(), 1);
    PartitionWithoutSD partitionWithoutSD = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0);
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(Lists.newArrayList(partition), Lists.newArrayList(partitionWithoutSD));
    client.add_partitions_pspec(partitionSpecProxy);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) 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)

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