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);
}
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();
}
}
}
Aggregations