Search in sources :

Example 41 with Catalog

use of org.apache.hadoop.hive.metastore.api.Catalog 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);
}
Also used : CatalogBuilder(org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder) Catalog(org.apache.hadoop.hive.metastore.api.Catalog)

Example 42 with Catalog

use of org.apache.hadoop.hive.metastore.api.Catalog 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());
}
Also used : DatabaseBuilder(org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder) ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) SchemaVersion(org.apache.hadoop.hive.metastore.api.SchemaVersion) CatalogBuilder(org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) Database(org.apache.hadoop.hive.metastore.api.Database) SchemaVersionBuilder(org.apache.hadoop.hive.metastore.client.builder.SchemaVersionBuilder) Catalog(org.apache.hadoop.hive.metastore.api.Catalog) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 43 with Catalog

use of org.apache.hadoop.hive.metastore.api.Catalog 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());
}
Also used : CatalogBuilder(org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder) Catalog(org.apache.hadoop.hive.metastore.api.Catalog) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

Aggregations

Catalog (org.apache.hadoop.hive.metastore.api.Catalog)43 CatalogBuilder (org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder)34 DatabaseBuilder (org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder)26 Test (org.junit.Test)23 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)19 TableBuilder (org.apache.hadoop.hive.metastore.client.builder.TableBuilder)19 Database (org.apache.hadoop.hive.metastore.api.Database)18 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)15 Table (org.apache.hadoop.hive.metastore.api.Table)11 ArrayList (java.util.ArrayList)8 Before (org.junit.Before)8 Partition (org.apache.hadoop.hive.metastore.api.Partition)6 PartitionBuilder (org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder)6 File (java.io.File)4 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)4 ISchema (org.apache.hadoop.hive.metastore.api.ISchema)4 ISchemaBuilder (org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)3