use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecUnsupportedPartSpecType.
@Test
public void testAddPartitionSpecUnsupportedPartSpecType() throws Exception {
createTable();
PartitionSpec partitionSpec = new PartitionSpec();
partitionSpec.setDbName(DB_NAME);
partitionSpec.setTableName(TABLE_NAME);
partitionSpec.setPartitionList(null);
partitionSpec.setSharedSDPartitionSpec(null);
try {
PartitionSpecProxy bubu = PartitionSpecProxy.Factory.get(partitionSpec);
client.add_partitions_pspec(bubu);
Assert.fail("AssertionError should have been thrown.");
} catch (AssertionError e) {
// Expected error
}
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecInvalidLocation.
@Test
public void testAddPartitionSpecInvalidLocation() throws Exception {
createTable();
String tableLocation = metaStore.getWarehouseRoot() + "/" + TABLE_NAME;
Map<String, String> valuesAndLocations = new HashMap<>();
valuesAndLocations.put("2014", tableLocation + "/year=2014");
valuesAndLocations.put("2015", tableLocation + "/year=2015");
valuesAndLocations.put("2016", "invalidhost:80000/wrongfolder");
valuesAndLocations.put("2017", tableLocation + "/year=2017");
valuesAndLocations.put("2018", tableLocation + "/year=2018");
List<Partition> partitions = buildPartitions(DB_NAME, TABLE_NAME, valuesAndLocations);
PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions);
try {
client.add_partitions_pspec(partitionSpecProxy);
Assert.fail("MetaException should have happened.");
} catch (MetaException e) {
// Expected exception
}
List<Partition> parts = client.listPartitions(DB_NAME, TABLE_NAME, MAX);
Assert.assertNotNull(parts);
Assert.assertTrue(parts.isEmpty());
for (Partition partition : partitions) {
if (!"invalidhost:80000/wrongfolder".equals(partition.getSd().getLocation())) {
Assert.assertFalse(metaStore.isPathExists(new Path(partition.getSd().getLocation())));
}
}
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecEmptyLocation.
@Test
public void testAddPartitionSpecEmptyLocation() throws Exception {
Table table = createTable();
Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, "");
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 testAddPartitionSpecEmptyPartList.
@Test
public void testAddPartitionSpecEmptyPartList() throws Exception {
createTable();
List<Partition> partitions = new ArrayList<>();
PartitionSpecProxy partitionSpec = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions);
client.add_partitions_pspec(partitionSpec);
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy 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);
}
Aggregations