public Object getFieldValue(_Fields field) { switch (field) { case SCHEMA_TYPE: return getSchemaType(); case NAME: return getName(); case CAT_NAME: return getCatName(); case DB_NAME: return getDbName(); case COMPATIBILITY: return getCompatibility(); case VALIDATION_LEVEL: return getValidationLevel(); case CAN_EVOLVE: return isCanEvolve(); case SCHEMA_GROUP: return getSchemaGroup(); case DESCRIPTION: return getDescription(); } throw new IllegalStateException(); }
private MISchema convertToMISchema(ISchema schema) throws NoSuchObjectException { return new MISchema(schema.getSchemaType().getValue(), normalizeIdentifier(schema.getName()), getMDatabase(schema.getCatName(), schema.getDbName()), schema.getCompatibility().getValue(), schema.getValidationLevel().getValue(), schema.isCanEvolve(), schema.isSetSchemaGroup() ? schema.getSchemaGroup() : null, schema.isSetDescription() ? schema.getDescription() : null); }
@Override public void alterISchema(ISchemaName schemaName, ISchema newSchema) throws NoSuchObjectException, MetaException { boolean committed = false; try { openTransaction(); MISchema oldMSchema = getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName()); if (oldMSchema == null) { throw new NoSuchObjectException("Schema " + schemaName + " does not exist"); } // Don't support changing name or type oldMSchema.setCompatibility(newSchema.getCompatibility().getValue()); oldMSchema.setValidationLevel(newSchema.getValidationLevel().getValue()); oldMSchema.setCanEvolve(newSchema.isCanEvolve()); if (newSchema.isSetSchemaGroup()) { oldMSchema.setSchemaGroup(newSchema.getSchemaGroup()); } if (newSchema.isSetDescription()) { oldMSchema.setDescription(newSchema.getDescription()); } committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
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()); 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());
@Test(expected = AlreadyExistsException.class) public void schemaAlreadyExists() throws TException { String schemaName = uniqueSchemaName(); ISchema schema = new ISchemaBuilder() .setSchemaType(SchemaType.HIVE) .setName(schemaName) .build(); client.createISchema(schema); 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 client.createISchema(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); }
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()); 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());
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()); 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());
private MISchema convertToMISchema(ISchema schema) throws NoSuchObjectException { return new MISchema(schema.getSchemaType().getValue(), normalizeIdentifier(schema.getName()), getMDatabase(schema.getCatName(), schema.getDbName()), schema.getCompatibility().getValue(), schema.getValidationLevel().getValue(), schema.isCanEvolve(), schema.isSetSchemaGroup() ? schema.getSchemaGroup() : null, schema.isSetDescription() ? schema.getDescription() : null); }
@Override public void alterISchema(ISchemaName schemaName, ISchema newSchema) throws NoSuchObjectException, MetaException { boolean committed = false; try { openTransaction(); MISchema oldMSchema = getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName()); if (oldMSchema == null) { throw new NoSuchObjectException("Schema " + schemaName + " does not exist"); } // Don't support changing name or type oldMSchema.setCompatibility(newSchema.getCompatibility().getValue()); oldMSchema.setValidationLevel(newSchema.getValidationLevel().getValue()); oldMSchema.setCanEvolve(newSchema.isCanEvolve()); if (newSchema.isSetSchemaGroup()) { oldMSchema.setSchemaGroup(newSchema.getSchemaGroup()); } if (newSchema.isSetDescription()) { oldMSchema.setDescription(newSchema.getDescription()); } committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }