use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecNullValue.
@Test
public void testAddPartitionSpecNullValue() throws Exception {
createTable();
Partition partition = buildPartition(DB_NAME, TABLE_NAME, null);
PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition));
try {
client.add_partitions_pspec(partitionSpecProxy);
} catch (NullPointerException e) {
// TODO: NPE should not be thrown
}
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class HiveMetaStoreClient method alter_table_with_environmentContext.
@Override
public void alter_table_with_environmentContext(String dbname, String tbl_name, Table new_tbl, EnvironmentContext envContext) throws InvalidOperationException, MetaException, TException {
HiveMetaHook hook = getHook(new_tbl);
if (hook != null) {
hook.preAlterTable(new_tbl, envContext);
}
AlterTableRequest req = new AlterTableRequest(dbname, tbl_name, new_tbl);
req.setCatName(MetaStoreUtils.getDefaultCatalog(conf));
req.setEnvironmentContext(envContext);
if (processorCapabilities != null) {
req.setProcessorCapabilities(new ArrayList<String>(Arrays.asList(processorCapabilities)));
req.setProcessorIdentifier(processorIdentifier);
}
boolean success = false;
try {
client.alter_table_req(req);
if (hook != null) {
PartitionSpecProxy partitionSpecProxy = listPartitionSpecs(dbname, tbl_name, Integer.MAX_VALUE);
hook.commitAlterTable(new_tbl, envContext, partitionSpecProxy);
}
success = true;
} finally {
if (!success && (hook != null)) {
hook.rollbackAlterTable(new_tbl, envContext);
}
}
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecChangeRootPathDiffInSd.
@Test(expected = MetaException.class)
public void testAddPartitionSpecChangeRootPathDiffInSd() throws Exception {
Table table = createTable();
String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/";
String rootPath1 = table.getSd().getLocation() + "/addPartSdPath/";
String rootPath2 = table.getSd().getLocation() + "/someotherpath/";
Partition partition = buildPartition(DB_NAME, TABLE_NAME, "2007", rootPath1 + "part2007/");
PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath, Lists.newArrayList(partition));
partitionSpecProxy.setRootLocation(rootPath2);
client.add_partitions_pspec(partitionSpecProxy);
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecDiffDBName.
@Test
public void testAddPartitionSpecDiffDBName() throws Exception {
createDB("NewPartDB");
createTable();
createTable("NewPartDB", "NewPartTable", getYearPartCol(), null);
List<Partition> partitions = new ArrayList<>();
Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE);
Partition partition2 = buildPartition("NewPartDB", "NewPartTable", DEFAULT_YEAR_VALUE);
partitions.add(partition1);
partitions.add(partition2);
PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions);
try {
client.add_partitions_pspec(partitionSpecProxy);
Assert.fail("MetaException should have been thrown.");
} catch (MetaException e) {
// Expected exception
} finally {
client.dropDatabase("NewPartDB", true, true, true);
}
}
use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.
the class TestAddPartitionsFromPartSpec method testAddPartitionSpecNoDB.
@Test(expected = MetaException.class)
public void testAddPartitionSpecNoDB() throws Exception {
createTable();
Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE);
PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(null, TABLE_NAME, null, Lists.newArrayList(partition));
client.add_partitions_pspec(partitionSpecProxy);
}
Aggregations