public ISchemaName deepCopy() { return new ISchemaName(this); }
/** * Performs a deep copy on <i>other</i>. */ public SchemaVersionDescriptor(SchemaVersionDescriptor other) { __isset_bitfield = other.__isset_bitfield; if (other.isSetSchema()) { this.schema = new ISchemaName(other.schema); } this.version = other.version; }
@Override public SchemaVersion getSchemaLatestVersion(String catName, String dbName, String schemaName) throws TException { return client.get_schema_latest_version(new ISchemaName(catName, dbName, schemaName)); }
@Override public List<SchemaVersion> getSchemaAllVersions(String catName, String dbName, String schemaName) throws TException { return client.get_schema_all_versions(new ISchemaName(catName, dbName, schemaName)); }
@Override public void alterISchema(String catName, String dbName, String schemaName, ISchema newSchema) throws TException { client.alter_ischema(new AlterISchemaRequest(new ISchemaName(catName, dbName, schemaName), newSchema)); }
@Override public void dropISchema(String catName, String dbName, String name) throws TException { client.drop_ischema(new ISchemaName(catName, dbName, name)); }
@Override public void dropSchemaVersion(String catName, String dbName, String schemaName, int version) throws TException { client.drop_schema_version(new SchemaVersionDescriptor(new ISchemaName(catName, dbName, schemaName), version)); }
@Override public SchemaVersion getSchemaVersion(String catName, String dbName, String schemaName, int version) throws TException { return client.get_schema_version(new SchemaVersionDescriptor(new ISchemaName(catName, dbName, schemaName), version)); }
@Override public ISchema getISchema(String catName, String dbName, String name) throws TException { return client.get_ischema(new ISchemaName(catName, dbName, name)); }
@Override public void setSchemaVersionState(String catName, String dbName, String schemaName, int version, SchemaVersionState state) throws TException { client.set_schema_version_state(new SetSchemaVersionStateRequest(new SchemaVersionDescriptor( new ISchemaName(catName, dbName, schemaName), version), state)); }
@Override public void mapSchemaVersionToSerde(String catName, String dbName, String schemaName, int version, String serdeName) throws TException { client.map_schema_version_to_serde(new MapSchemaVersionToSerdeRequest( new SchemaVersionDescriptor(new ISchemaName(catName, dbName, schemaName), version), serdeName)); }
/** * Performs a deep copy on <i>other</i>. */ public AlterISchemaRequest(AlterISchemaRequest other) { if (other.isSetName()) { this.name = new ISchemaName(other.name); } if (other.isSetNewSchema()) { this.newSchema = new ISchema(other.newSchema); } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, SchemaVersionDescriptor struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.schema = new ISchemaName(); struct.schema.read(iprot); struct.setSchemaIsSet(true); } if (incoming.get(1)) { struct.version = iprot.readI32(); struct.setVersionIsSet(true); } } }
@Test(expected = NoSuchObjectException.class) public void dropNonExistentSchemaVersion() throws NoSuchObjectException, MetaException { objectStore.dropSchemaVersion(new SchemaVersionDescriptor(new ISchemaName(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME, "ther is no schema named this"), 23)); }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, AlterISchemaRequest struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.name = new ISchemaName(); struct.name.read(iprot); struct.setNameIsSet(true); } if (incoming.get(1)) { struct.newSchema = new ISchema(); struct.newSchema.read(iprot); struct.setNewSchemaIsSet(true); } } }
public SchemaVersion build() throws MetaException { if (schemaName == null || version < 0) { throw new MetaException("You must provide the schema name, and schema version"); } SchemaVersion schemaVersion = new SchemaVersion(new ISchemaName(catName, dbName, schemaName), version, createdAt, getCols()); if (state != null) schemaVersion.setState(state); if (description != null) schemaVersion.setDescription(description); if (schemaText != null) schemaVersion.setSchemaText(schemaText); if (fingerprint != null) schemaVersion.setFingerprint(fingerprint); if (name != null) schemaVersion.setName(name); schemaVersion.setSerDe(buildSerde()); return schemaVersion; } }
@Test(expected = NoSuchObjectException.class) public void dropNonExistentSchema() throws MetaException, NoSuchObjectException { objectStore.dropISchema(new ISchemaName(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME, "no_such_schema")); }
@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); }
@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); }
@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); }