use of org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder in project hive by apache.
the class TestObjectStoreSchemaMethods method createUniqueDatabaseForTest.
private Database createUniqueDatabaseForTest() throws MetaException, InvalidObjectException {
String catName;
if (rand.nextDouble() < 0.5) {
catName = "unique_cat_for_test_" + dbNum++;
objectStore.createCatalog(new CatalogBuilder().setName(catName).setLocation("there").build());
} else {
catName = DEFAULT_CATALOG_NAME;
}
String dbName = "uniquedbfortest" + dbNum++;
Database db = new DatabaseBuilder().setName(dbName).setCatalogName(catName).setLocation("somewhere").setDescription("descriptive").build(conf);
objectStore.createDatabase(db);
return db;
}
use of org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder in project hive by apache.
the class TestStats method createMetadata.
private List<String> createMetadata(String catName, String dbName, String tableName, String partKey, List<String> partVals, Map<String, Column> colMap) throws TException {
if (!DEFAULT_CATALOG_NAME.equals(catName) && !NO_CAT.equals(catName)) {
Catalog cat = new CatalogBuilder().setName(catName).setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName)).build();
client.createCatalog(cat);
}
Database db;
if (!DEFAULT_DATABASE_NAME.equals(dbName)) {
DatabaseBuilder dbBuilder = new DatabaseBuilder().setName(dbName);
if (!NO_CAT.equals(catName))
dbBuilder.setCatalogName(catName);
db = dbBuilder.create(client, conf);
} else {
db = client.getDatabase(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME);
}
TableBuilder tb = new TableBuilder().inDb(db).setTableName(tableName);
for (Column col : colMap.values()) tb.addCol(col.colName, col.colType);
if (partKey != null) {
assert partVals != null && !partVals.isEmpty() : "Must provide partition values for partitioned table";
tb.addPartCol(partKey, ColumnType.STRING_TYPE_NAME);
}
Table table = tb.create(client, conf);
if (partKey != null) {
for (String partVal : partVals) {
new PartitionBuilder().inTable(table).addValue(partVal).addToTable(client, conf);
}
}
SetPartitionsStatsRequest rqst = new SetPartitionsStatsRequest();
List<String> partNames = new ArrayList<>();
if (partKey == null) {
rqst.addToColStats(buildStatsForOneTableOrPartition(catName, dbName, tableName, null, colMap.values()));
} else {
for (String partVal : partVals) {
String partName = partKey + "=" + partVal;
rqst.addToColStats(buildStatsForOneTableOrPartition(catName, dbName, tableName, partName, colMap.values()));
partNames.add(partName);
}
}
rqst.setEngine(ENGINE);
client.setPartitionColumnStatistics(rqst);
return partNames;
}
use of org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder in project hive by apache.
the class TestCatalogs method dropNonEmptyCatalog.
@Test(expected = InvalidOperationException.class)
public void dropNonEmptyCatalog() throws TException {
String catName = "toBeDropped";
Catalog cat = new CatalogBuilder().setName(catName).setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName)).build();
client.createCatalog(cat);
String dbName = "dontDropMe";
new DatabaseBuilder().setName(dbName).setCatalogName(catName).create(client, metaStore.getConf());
client.dropCatalog(catName);
}
use of org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder 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.CatalogBuilder in project hive by apache.
the class TestCatalogs method alterNonExistentCatalog.
@Test(expected = NoSuchObjectException.class)
public void alterNonExistentCatalog() throws TException {
String catName = "alter_no_such_catalog";
Catalog cat = new CatalogBuilder().setName(catName).setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName)).build();
client.alterCatalog(catName, cat);
}
Aggregations