use of org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder in project hive by apache.
the class TestObjectStore method createTestCatalog.
private void createTestCatalog(String catName) throws MetaException {
Catalog cat = new CatalogBuilder().setName(catName).setLocation("/tmp").build();
objectStore.createCatalog(cat);
}
use of org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder in project hive by apache.
the class TestHiveMetaStoreSchemaMethods method setVersionStateOtherDb.
@Test
public void setVersionStateOtherDb() throws TException {
String catName = "other_cat_for_set_version";
Catalog cat = new CatalogBuilder().setName(catName).setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName)).build();
client.createCatalog(cat);
String dbName = "other_db_set_state";
Database db = new DatabaseBuilder().setName(dbName).setCatalogName(catName).create(client, conf);
String schemaName = uniqueSchemaName();
ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.AVRO).setName(schemaName).inDb(db).build();
client.createISchema(schema);
SchemaVersion schemaVersion = new SchemaVersionBuilder().versionOf(schema).setVersion(1).addCol("a", ColumnType.BINARY_TYPE_NAME).build();
client.addSchemaVersion(schemaVersion);
schemaVersion = client.getSchemaVersion(catName, dbName, schemaName, 1);
Assert.assertNull(schemaVersion.getState());
client.setSchemaVersionState(catName, dbName, schemaName, 1, SchemaVersionState.INITIATED);
Assert.assertEquals(1, (int) preEvents.get(PreEventContext.PreEventType.ALTER_SCHEMA_VERSION));
Assert.assertEquals(1, (int) events.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
Assert.assertEquals(1, (int) transactionalEvents.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
schemaVersion = client.getSchemaVersion(catName, dbName, schemaName, 1);
Assert.assertEquals(SchemaVersionState.INITIATED, schemaVersion.getState());
client.setSchemaVersionState(catName, dbName, schemaName, 1, SchemaVersionState.REVIEWED);
Assert.assertEquals(2, (int) preEvents.get(PreEventContext.PreEventType.ALTER_SCHEMA_VERSION));
Assert.assertEquals(2, (int) events.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
Assert.assertEquals(2, (int) transactionalEvents.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
schemaVersion = client.getSchemaVersion(catName, dbName, schemaName, 1);
Assert.assertEquals(SchemaVersionState.REVIEWED, schemaVersion.getState());
}
use of org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder in project hive by apache.
the class TestObjectStore method catalogs.
@Test
public void catalogs() throws MetaException, NoSuchObjectException {
final String[] names = { "cat1", "cat2" };
final String[] locations = { "loc1", "loc2" };
final String[] descriptions = { "description 1", "description 2" };
for (int i = 0; i < names.length; i++) {
Catalog cat = new CatalogBuilder().setName(names[i]).setLocation(locations[i]).setDescription(descriptions[i]).build();
objectStore.createCatalog(cat);
}
List<String> fetchedNames = objectStore.getCatalogs();
Assert.assertEquals(3, fetchedNames.size());
for (int i = 0; i < names.length - 1; i++) {
Assert.assertEquals(names[i], fetchedNames.get(i));
Catalog cat = objectStore.getCatalog(fetchedNames.get(i));
Assert.assertEquals(names[i], cat.getName());
Assert.assertEquals(descriptions[i], cat.getDescription());
Assert.assertEquals(locations[i], cat.getLocationUri());
}
Catalog cat = objectStore.getCatalog(fetchedNames.get(2));
Assert.assertEquals(DEFAULT_CATALOG_NAME, cat.getName());
Assert.assertEquals(Warehouse.DEFAULT_CATALOG_COMMENT, cat.getDescription());
for (int i = 0; i < names.length; i++) objectStore.dropCatalog(names[i]);
fetchedNames = objectStore.getCatalogs();
Assert.assertEquals(1, fetchedNames.size());
}
Aggregations