Search in sources :

Example 6 with ISchemaName

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);
}
Also used : ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) ISchemaName(org.apache.hadoop.hive.metastore.api.ISchemaName) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 7 with ISchemaName

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);
}
Also used : SchemaVersion(org.apache.hadoop.hive.metastore.api.SchemaVersion) SchemaVersionDescriptor(org.apache.hadoop.hive.metastore.api.SchemaVersionDescriptor) SchemaVersionBuilder(org.apache.hadoop.hive.metastore.client.builder.SchemaVersionBuilder) ISchemaName(org.apache.hadoop.hive.metastore.api.ISchemaName) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 8 with ISchemaName

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);
}
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 9 with ISchemaName

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

Aggregations

ISchemaName (org.apache.hadoop.hive.metastore.api.ISchemaName)9 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)8 Test (org.junit.Test)8 ISchema (org.apache.hadoop.hive.metastore.api.ISchema)7 ISchemaBuilder (org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder)7 Database (org.apache.hadoop.hive.metastore.api.Database)6 SchemaVersion (org.apache.hadoop.hive.metastore.api.SchemaVersion)6 SchemaVersionBuilder (org.apache.hadoop.hive.metastore.client.builder.SchemaVersionBuilder)5 SchemaVersionDescriptor (org.apache.hadoop.hive.metastore.api.SchemaVersionDescriptor)4 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 SerDeInfo (org.apache.hadoop.hive.metastore.api.SerDeInfo)1