use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy 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));
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecNullLocation.
@Test
public void testAddPartitionSpecNullLocation() throws Exception {
Table table = createTable();
Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, null);
PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition));
client.add_partitions_pspec(partitionSpecProxy);
Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList(DEFAULT_YEAR_VALUE));
Assert.assertEquals(table.getSd().getLocation() + "/year=2017", resultPart.getSd().getLocation());
Assert.assertTrue(metaStore.isPathExists(new Path(resultPart.getSd().getLocation())));
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy 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);
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecChangeRootPathToNull.
@Test(expected = MetaException.class)
public void testAddPartitionSpecChangeRootPathToNull() throws Exception {
Table table = createTable();
String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/";
Partition partition = buildPartition(DB_NAME, TABLE_NAME, "2007", rootPath + "part2007/");
PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath, Lists.newArrayList(partition));
partitionSpecProxy.setRootLocation(null);
client.add_partitions_pspec(partitionSpecProxy);
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy 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())));
}
Aggregations