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 {
String dbName = createUniqueDatabaseForTest();
String schemaName = "schema2";
ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.HIVE).setName(schemaName).setDbName(dbName).build();
objectStore.createISchema(schema);
schema = objectStore.getISchema(new ISchemaName(dbName, 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 TestObjectStoreSchemaMethods method alterNonExistentSchema.
@Test(expected = NoSuchObjectException.class)
public void alterNonExistentSchema() throws MetaException, NoSuchObjectException {
String schemaName = "noSuchSchema";
ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.HIVE).setName(schemaName).setDescription("a new description").build();
objectStore.alterISchema(new ISchemaName(DEFAULT_DATABASE_NAME, schemaName), schema);
}
use of org.apache.hadoop.hive.metastore.api.ISchema in project hive by apache.
the class TestObjectStoreSchemaMethods method iSchema.
@Test
public void iSchema() throws TException {
String dbName = createUniqueDatabaseForTest();
ISchema schema = objectStore.getISchema(new ISchemaName(dbName, "no.such.schema"));
Assert.assertNull(schema);
String schemaName = "schema1";
String schemaGroup = "group1";
String description = "This is a description";
schema = new ISchemaBuilder().setSchemaType(SchemaType.AVRO).setName(schemaName).setDbName(dbName).setCompatibility(SchemaCompatibility.FORWARD).setValidationLevel(SchemaValidation.LATEST).setCanEvolve(false).setSchemaGroup(schemaGroup).setDescription(description).build();
objectStore.createISchema(schema);
schema = objectStore.getISchema(new ISchemaName(dbName, schemaName));
Assert.assertNotNull(schema);
Assert.assertEquals(SchemaType.AVRO, schema.getSchemaType());
Assert.assertEquals(schemaName, schema.getName());
Assert.assertEquals(SchemaCompatibility.FORWARD, schema.getCompatibility());
Assert.assertEquals(SchemaValidation.LATEST, schema.getValidationLevel());
Assert.assertFalse(schema.isCanEvolve());
Assert.assertEquals(schemaGroup, schema.getSchemaGroup());
Assert.assertEquals(description, schema.getDescription());
schemaGroup = "new group";
description = "new description";
schema.setCompatibility(SchemaCompatibility.BOTH);
schema.setValidationLevel(SchemaValidation.ALL);
schema.setCanEvolve(true);
schema.setSchemaGroup(schemaGroup);
schema.setDescription(description);
objectStore.alterISchema(new ISchemaName(dbName, schemaName), schema);
schema = objectStore.getISchema(new ISchemaName(dbName, schemaName));
Assert.assertNotNull(schema);
Assert.assertEquals(SchemaType.AVRO, schema.getSchemaType());
Assert.assertEquals(schemaName, schema.getName());
Assert.assertEquals(SchemaCompatibility.BOTH, schema.getCompatibility());
Assert.assertEquals(SchemaValidation.ALL, schema.getValidationLevel());
Assert.assertTrue(schema.isCanEvolve());
Assert.assertEquals(schemaGroup, schema.getSchemaGroup());
Assert.assertEquals(description, schema.getDescription());
objectStore.dropISchema(new ISchemaName(dbName, schemaName));
schema = objectStore.getISchema(new ISchemaName(dbName, schemaName));
Assert.assertNull(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.getDbName(), schemaName.getSchemaName()));
committed = commitTransaction();
return schema;
} finally {
if (!committed)
rollbackTransaction();
}
}
Aggregations