use of org.apache.hadoop.hive.metastore.api.ISchemaName 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_CATALOG_NAME, DEFAULT_DATABASE_NAME, schemaName), schema);
}
use of org.apache.hadoop.hive.metastore.api.ISchemaName in project hive by apache.
the class TestObjectStoreSchemaMethods method alterNonExistentSchemaVersion.
@Test(expected = NoSuchObjectException.class)
public void alterNonExistentSchemaVersion() throws MetaException, AlreadyExistsException, NoSuchObjectException {
String schemaName = "schema3723asdflj";
int version = 37;
SchemaVersion schemaVersion = new SchemaVersionBuilder().setSchemaName(schemaName).setDbName(DEFAULT_DATABASE_NAME).setVersion(version).addCol("a", ColumnType.INT_TYPE_NAME).addCol("b", ColumnType.FLOAT_TYPE_NAME).setState(SchemaVersionState.INITIATED).build();
objectStore.alterSchemaVersion(new SchemaVersionDescriptor(new ISchemaName(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME, schemaName), version), schemaVersion);
}
use of org.apache.hadoop.hive.metastore.api.ISchemaName in project hive by apache.
the class TestObjectStoreSchemaMethods method iSchema.
@Test
public void iSchema() throws TException {
Database db = createUniqueDatabaseForTest();
ISchema schema = objectStore.getISchema(new ISchemaName(db.getCatalogName(), db.getName(), "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).inDb(db).setCompatibility(SchemaCompatibility.FORWARD).setValidationLevel(SchemaValidation.LATEST).setCanEvolve(false).setSchemaGroup(schemaGroup).setDescription(description).build();
objectStore.createISchema(schema);
schema = objectStore.getISchema(new ISchemaName(db.getCatalogName(), db.getName(), 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(db.getCatalogName(), db.getName(), schemaName), schema);
schema = objectStore.getISchema(new ISchemaName(db.getCatalogName(), db.getName(), 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(db.getCatalogName(), db.getName(), schemaName));
schema = objectStore.getISchema(new ISchemaName(db.getCatalogName(), db.getName(), schemaName));
Assert.assertNull(schema);
}
use of org.apache.hadoop.hive.metastore.api.ISchemaName 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);
}
Aggregations