Search in sources :

Example 21 with ISchema

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

the class TestHiveMetaStoreSchemaMethods method addDuplicateSchemaVersion.

@Test(expected = AlreadyExistsException.class)
public void addDuplicateSchemaVersion() throws TException {
    String schemaName = uniqueSchemaName();
    int version = 1;
    ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.AVRO).setName(schemaName).build();
    client.createISchema(schema);
    SchemaVersion schemaVersion = new SchemaVersionBuilder().versionOf(schema).setVersion(version).addCol("a", ColumnType.INT_TYPE_NAME).addCol("b", ColumnType.FLOAT_TYPE_NAME).build();
    client.addSchemaVersion(schemaVersion);
    client.addSchemaVersion(schemaVersion);
}
Also used : ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) SchemaVersion(org.apache.hadoop.hive.metastore.api.SchemaVersion) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) SchemaVersionBuilder(org.apache.hadoop.hive.metastore.client.builder.SchemaVersionBuilder) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 22 with ISchema

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

the class TestHiveMetaStoreSchemaMethods method setVersionStateOtherDb.

@Test
public void setVersionStateOtherDb() throws TException {
    String dbName = "other_db_set_state";
    Database db = new DatabaseBuilder().setName(dbName).build();
    client.createDatabase(db);
    String schemaName = uniqueSchemaName();
    ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.AVRO).setName(schemaName).setDbName(dbName).build();
    client.createISchema(schema);
    SchemaVersion schemaVersion = new SchemaVersionBuilder().versionOf(schema).setVersion(1).addCol("a", ColumnType.BINARY_TYPE_NAME).build();
    client.addSchemaVersion(schemaVersion);
    schemaVersion = client.getSchemaVersion(dbName, schemaName, 1);
    Assert.assertNull(schemaVersion.getState());
    client.setSchemaVersionState(dbName, schemaName, 1, SchemaVersionState.INITIATED);
    Assert.assertEquals(1, (int) preEvents.get(PreEventContext.PreEventType.ALTER_SCHEMA_VERSION));
    Assert.assertEquals(1, (int) events.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
    Assert.assertEquals(1, (int) transactionalEvents.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
    schemaVersion = client.getSchemaVersion(dbName, schemaName, 1);
    Assert.assertEquals(SchemaVersionState.INITIATED, schemaVersion.getState());
    client.setSchemaVersionState(dbName, schemaName, 1, SchemaVersionState.REVIEWED);
    Assert.assertEquals(2, (int) preEvents.get(PreEventContext.PreEventType.ALTER_SCHEMA_VERSION));
    Assert.assertEquals(2, (int) events.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
    Assert.assertEquals(2, (int) transactionalEvents.get(EventMessage.EventType.ALTER_SCHEMA_VERSION));
    schemaVersion = client.getSchemaVersion(dbName, schemaName, 1);
    Assert.assertEquals(SchemaVersionState.REVIEWED, schemaVersion.getState());
}
Also used : DatabaseBuilder(org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder) ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) SchemaVersion(org.apache.hadoop.hive.metastore.api.SchemaVersion) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) Database(org.apache.hadoop.hive.metastore.api.Database) SchemaVersionBuilder(org.apache.hadoop.hive.metastore.client.builder.SchemaVersionBuilder) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 23 with ISchema

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

the class TestHiveMetaStoreSchemaMethods method nonExistentSchemaVersion.

@Test(expected = NoSuchObjectException.class)
public void nonExistentSchemaVersion() throws TException {
    String schemaName = uniqueSchemaName();
    ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.AVRO).setName(schemaName).build();
    client.createISchema(schema);
    client.getSchemaVersion(DEFAULT_DATABASE_NAME, schemaName, 1);
}
Also used : ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 24 with ISchema

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

the class TestHiveMetaStoreSchemaMethods method schemaVersionBogusDb.

@Test(expected = NoSuchObjectException.class)
public void schemaVersionBogusDb() throws TException {
    String schemaName = uniqueSchemaName();
    ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.AVRO).setName(schemaName).build();
    client.createISchema(schema);
    client.getSchemaVersion("bogus", schemaName, 1);
}
Also used : ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 25 with ISchema

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

the class TestHiveMetaStoreSchemaMethods method allSchemaVersionBogusDb.

@Test(expected = NoSuchObjectException.class)
public void allSchemaVersionBogusDb() throws TException {
    String schemaName = uniqueSchemaName();
    ISchema schema = new ISchemaBuilder().setSchemaType(SchemaType.AVRO).setName(schemaName).build();
    client.createISchema(schema);
    client.getSchemaAllVersions("bogus", schemaName);
}
Also used : ISchemaBuilder(org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder) ISchema(org.apache.hadoop.hive.metastore.api.ISchema) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

ISchema (org.apache.hadoop.hive.metastore.api.ISchema)34 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)33 ISchemaBuilder (org.apache.hadoop.hive.metastore.client.builder.ISchemaBuilder)33 Test (org.junit.Test)33 SchemaVersion (org.apache.hadoop.hive.metastore.api.SchemaVersion)16 SchemaVersionBuilder (org.apache.hadoop.hive.metastore.client.builder.SchemaVersionBuilder)16 ISchemaName (org.apache.hadoop.hive.metastore.api.ISchemaName)7 Database (org.apache.hadoop.hive.metastore.api.Database)5 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)5 DatabaseBuilder (org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder)5 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 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