Search in sources :

Example 36 with ISchema

use of org.apache.hadoop.hive.metastore.api.ISchema in project hive by apache.

the class TestObjectStoreSchemaMethods method schemaAlreadyExists.

@Test(expected = AlreadyExistsException.class)
public void schemaAlreadyExists() throws TException {
    Database db = createUniqueDatabaseForTest();
    String schemaName = "schema2";
    ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.HIVE).setName(schemaName).inDb(db).build();
    objectStore.createISchema(schema);
    schema = objectStore.getISchema(new ISchemaName(db.getCatalogName(), db.getName(), schemaName));
    Assert.assertNotNull(schema);
    Assert.assertEquals(SchemaType.HIVE, schema.getSchemaType());
    Assert.assertEquals(schemaName, schema.getName());
    Assert.assertEquals(SchemaCompatibility.BACKWARD, schema.getCompatibility());
    Assert.assertEquals(SchemaValidation.ALL, schema.getValidationLevel());
    Assert.assertTrue(schema.isCanEvolve());
    // This second attempt to create it should throw
    objectStore.createISchema(schema);
}
Also used : ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) Database(org.apache.hadoop.hive.metastore.api.Database) ISchemaName(org.apache.hadoop.hive.metastore.api.ISchemaName) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 37 with ISchema

use of org.apache.hadoop.hive.metastore.api.ISchema in project hive by apache.

the class ObjectStore method getISchema.

@Override
public ISchema getISchema(ISchemaName schemaName) throws MetaException {
    boolean committed = false;
    try {
        openTransaction();
        ISchema schema = convertToISchema(getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName()));
        committed = commitTransaction();
        return schema;
    } finally {
        if (!committed) {
            rollbackTransaction();
        }
    }
}
Also used : MISchema(org.apache.hadoop.hive.metastore.model.MISchema) ISchema(org.apache.hadoop.hive.metastore.api.ISchema)

Aggregations

ISchema (org.apache.hadoop.hive.metastore.api.ISchema)37 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)36 ISchemaBuilder (org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder)36 Test (org.junit.Test)36 SchemaVersion (org.apache.hadoop.hive.metastore.api.SchemaVersion)16 SchemaVersionBuilder (org.apache.hadoop.hive.metastore.client.builder.SchemaVersionBuilder)16 Database (org.apache.hadoop.hive.metastore.api.Database)12 ISchemaName (org.apache.hadoop.hive.metastore.api.ISchemaName)7 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)5 DatabaseBuilder (org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder)5 Catalog (org.apache.hadoop.hive.metastore.api.Catalog)4 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)4 SchemaVersionDescriptor (org.apache.hadoop.hive.metastore.api.SchemaVersionDescriptor)4 SerDeInfo (org.apache.hadoop.hive.metastore.api.SerDeInfo)4 CatalogBuilder (org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder)4 ArrayList (java.util.ArrayList)1 FindSchemasByColsResp (org.apache.hadoop.hive.metastore.api.FindSchemasByColsResp)1 FindSchemasByColsRqst (org.apache.hadoop.hive.metastore.api.FindSchemasByColsRqst)1 MISchema (org.apache.hadoop.hive.metastore.model.MISchema)1