use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.
the class TestCatalogs method dropCatalogWithNonEmptyDefaultDb.
@Test(expected = InvalidOperationException.class)
public void dropCatalogWithNonEmptyDefaultDb() throws TException {
String catName = "toBeDropped2";
new CatalogBuilder().setName(catName).setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName)).create(client);
new TableBuilder().setTableName("not_droppable").setCatName(catName).addCol("cola1", "bigint").create(client, metaStore.getConf());
client.dropCatalog(catName);
}
use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.
the class TestDatabases method testDropDatabaseWithTableCascade.
@Test
public void testDropDatabaseWithTableCascade() throws Exception {
Database database = testDatabases[0];
Table testTable = new TableBuilder().setDbName(database.getName()).setTableName("test_table").addCol("test_col", "int").create(client, metaStore.getConf());
client.dropDatabase(database.getName(), true, true, true);
Assert.assertFalse("The directory should be removed", metaStore.isPathExists(new Path(database.getLocationUri())));
}
use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.
the class TestDatabases method testDropDatabaseWithTable.
@Test(expected = InvalidOperationException.class)
public void testDropDatabaseWithTable() throws Exception {
Database database = testDatabases[0];
Table testTable = new TableBuilder().setDbName(database.getName()).setTableName("test_table").addCol("test_col", "int").create(client, metaStore.getConf());
client.dropDatabase(database.getName(), true, true, false);
}
use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.
the class TestAlterPartitions method otherCatalog.
@Test
@ConditionalIgnoreOnSessionHiveMetastoreClient
public void otherCatalog() throws TException {
String catName = "alter_partition_catalog";
Catalog cat = new CatalogBuilder().setName(catName).setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName)).build();
client.createCatalog(cat);
String dbName = "alter_partition_database_in_other_catalog";
Database db = new DatabaseBuilder().setName(dbName).setCatalogName(catName).create(client, metaStore.getConf());
String tableName = "table_in_other_catalog";
Table table = new TableBuilder().inDb(db).setTableName(tableName).addCol("id", "int").addCol("name", "string").addPartCol("partcol", "string").create(client, metaStore.getConf());
Partition[] parts = new Partition[5];
for (int i = 0; i < 5; i++) {
parts[i] = new PartitionBuilder().inTable(table).addValue("a" + i).setLocation(MetaStoreTestUtils.getTestWarehouseDir("b" + i)).build(metaStore.getConf());
}
client.add_partitions(Arrays.asList(parts));
Partition newPart = client.getPartition(catName, dbName, tableName, Collections.singletonList("a0"));
newPart.getParameters().put("test_key", "test_value");
client.alter_partition(catName, dbName, tableName, newPart);
Partition fetched = client.getPartition(catName, dbName, tableName, Collections.singletonList("a0"));
Assert.assertEquals(catName, fetched.getCatName());
Assert.assertEquals("test_value", fetched.getParameters().get("test_key"));
newPart = client.getPartition(catName, dbName, tableName, Collections.singletonList("a1"));
newPart.setLastAccessTime(3);
Partition newPart1 = client.getPartition(catName, dbName, tableName, Collections.singletonList("a2"));
newPart1.getSd().setLocation(MetaStoreTestUtils.getTestWarehouseDir("somewhere"));
client.alter_partitions(catName, dbName, tableName, Arrays.asList(newPart, newPart1));
fetched = client.getPartition(catName, dbName, tableName, Collections.singletonList("a1"));
Assert.assertEquals(catName, fetched.getCatName());
Assert.assertEquals(3L, fetched.getLastAccessTime());
fetched = client.getPartition(catName, dbName, tableName, Collections.singletonList("a2"));
Assert.assertEquals(catName, fetched.getCatName());
Assert.assertTrue(fetched.getSd().getLocation().contains("somewhere"));
newPart = client.getPartition(catName, dbName, tableName, Collections.singletonList("a4"));
newPart.getParameters().put("test_key", "test_value");
EnvironmentContext ec = new EnvironmentContext();
ec.setProperties(Collections.singletonMap("a", "b"));
client.alter_partition(catName, dbName, tableName, newPart, ec);
fetched = client.getPartition(catName, dbName, tableName, Collections.singletonList("a4"));
Assert.assertEquals(catName, fetched.getCatName());
Assert.assertEquals("test_value", fetched.getParameters().get("test_key"));
client.dropDatabase(catName, dbName, true, true, true);
client.dropCatalog(catName);
}
use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.
the class TestAddPartitions method noSuchCatalog.
@Test(expected = InvalidObjectException.class)
@ConditionalIgnoreOnSessionHiveMetastoreClient
public void noSuchCatalog() throws TException {
String tableName = "table_for_no_such_catalog";
Table table = new TableBuilder().setTableName(tableName).addCol("id", "int").addCol("name", "string").addPartCol("partcol", "string").create(client, metaStore.getConf());
Partition part = new PartitionBuilder().inTable(table).addValue("a").build(metaStore.getConf());
// Explicitly mis-set the catalog name
part.setCatName("nosuch");
client.add_partition(part);
}
Aggregations