public Object getFieldValue(_Fields field) { switch (field) { case CAT_NAME: return getCatName(); case DB_NAME: return getDbName(); case SCHEMA_NAME: return getSchemaName(); } throw new IllegalStateException(); }
@Override public ISchema getISchema(ISchemaName schemaName) throws MetaException { boolean committed = false; try { openTransaction(); ISchema schema = convertToISchema(getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName())); committed = commitTransaction(); return schema; } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void dropISchema(ISchemaName schemaName) throws NoSuchObjectException, MetaException { boolean committed = false; try { openTransaction(); MISchema mSchema = getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName()); if (mSchema != null) { pm.deletePersistentAll(mSchema); } else { throw new NoSuchObjectException("Schema " + schemaName + " does not exist"); } committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
openTransaction(); String name = normalizeIdentifier(schemaName.getSchemaName()); String dbName = normalizeIdentifier(schemaName.getDbName()); String catName = normalizeIdentifier(schemaName.getCatName()); query = pm.newQuery(MSchemaVersion.class, "iSchema.name == schemaName &&" +
@Override public SchemaVersion getSchemaVersion(SchemaVersionDescriptor version) throws MetaException { boolean committed = false; try { openTransaction(); SchemaVersion schemaVersion = convertToSchemaVersion(getMSchemaVersion( version.getSchema().getCatName(), version.getSchema().getDbName(), version.getSchema().getSchemaName(), version.getVersion())); committed = commitTransaction(); return schemaVersion; } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void dropSchemaVersion(SchemaVersionDescriptor version) throws NoSuchObjectException, MetaException { boolean committed = false; try { openTransaction(); MSchemaVersion mSchemaVersion = getMSchemaVersion(version.getSchema().getCatName(), version.getSchema().getDbName(), version.getSchema().getSchemaName(), version.getVersion()); if (mSchemaVersion != null) { pm.deletePersistentAll(mSchemaVersion); } else { throw new NoSuchObjectException("Schema version " + version + "does not exist"); } committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void addSchemaVersion(SchemaVersion schemaVersion) throws AlreadyExistsException, NoSuchObjectException, MetaException { boolean committed = false; MSchemaVersion mSchemaVersion = convertToMSchemaVersion(schemaVersion); try { openTransaction(); // Make sure it doesn't already exist if (getMSchemaVersion(schemaVersion.getSchema().getCatName(), schemaVersion.getSchema().getDbName(), schemaVersion.getSchema().getSchemaName(), schemaVersion.getVersion()) != null) { throw new AlreadyExistsException("Schema name " + schemaVersion.getSchema() + " version " + schemaVersion.getVersion() + " already exists"); } // Make sure the referenced Schema exists if (getMISchema(schemaVersion.getSchema().getCatName(), schemaVersion.getSchema().getDbName(), schemaVersion.getSchema().getSchemaName()) == null) { throw new NoSuchObjectException("Schema " + schemaVersion.getSchema() + " does not exist"); } pm.makePersistent(mSchemaVersion); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void alterSchemaVersion(SchemaVersionDescriptor version, SchemaVersion newVersion) throws NoSuchObjectException, MetaException { boolean committed = false; try { openTransaction(); MSchemaVersion oldMSchemaVersion = getMSchemaVersion(version.getSchema().getCatName(), version.getSchema().getDbName(), version.getSchema().getSchemaName(), version.getVersion()); if (oldMSchemaVersion == null) { throw new NoSuchObjectException("No schema version " + version + " exists"); } // We only support changing the SerDe mapping and the state. if (newVersion.isSetSerDe()) { oldMSchemaVersion.setSerDe(convertToMSerDeInfo(newVersion.getSerDe())); } if (newVersion.isSetState()) { oldMSchemaVersion.setState(newVersion.getState().getValue()); } committed = commitTransaction(); } finally { if (!committed) { commitTransaction(); } } }
Assert.assertEquals(1, results.size()); Assert.assertEquals(schemaName1, results.get(0).getSchema().getSchemaName()); Assert.assertEquals(db.getName(), results.get(0).getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), results.get(0).getSchema().getCatName()); Assert.assertEquals(2, results.get(0).getVersion()); Collections.sort(results); Assert.assertEquals(schemaName1, results.get(0).getSchema().getSchemaName()); Assert.assertEquals(db.getName(), results.get(0).getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), results.get(0).getSchema().getCatName()); Assert.assertEquals(1, results.get(0).getVersion()); Assert.assertEquals(schemaName1, results.get(1).getSchema().getSchemaName()); Assert.assertEquals(db.getName(), results.get(1).getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), results.get(1).getSchema().getCatName()); Assert.assertEquals(2, results.get(1).getVersion()); Collections.sort(results); Assert.assertEquals(schemaName1, results.get(0).getSchema().getSchemaName()); Assert.assertEquals(db.getName(), results.get(0).getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), results.get(0).getSchema().getCatName()); Assert.assertEquals(1, results.get(0).getVersion()); Assert.assertEquals(schemaName1, results.get(1).getSchema().getSchemaName()); Assert.assertEquals(db.getName(), results.get(1).getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), results.get(1).getSchema().getCatName()); Assert.assertEquals(2, results.get(1).getVersion()); Assert.assertEquals(schemaName2, results.get(2).getSchema().getSchemaName()); Assert.assertEquals(db.getName(), results.get(2).getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), results.get(2).getSchema().getCatName()); Assert.assertEquals(1, results.get(2).getVersion());
Assert.assertEquals(1, rsp.getSchemaVersionsSize()); Assert.assertEquals(schemaName1, rsp.getSchemaVersions().get(0).getSchema().getSchemaName()); Assert.assertEquals(dbName, rsp.getSchemaVersions().get(0).getSchema().getDbName()); Assert.assertEquals(2, rsp.getSchemaVersions().get(0).getVersion()); Collections.sort(results); Assert.assertEquals(schemaName1, results.get(0).getSchema().getSchemaName()); Assert.assertEquals(dbName, results.get(0).getSchema().getDbName()); Assert.assertEquals(1, results.get(0).getVersion()); Assert.assertEquals(schemaName1, results.get(1).getSchema().getSchemaName()); Assert.assertEquals(dbName, results.get(1).getSchema().getDbName()); Assert.assertEquals(2, results.get(1).getVersion()); Collections.sort(results); Assert.assertEquals(schemaName1, results.get(0).getSchema().getSchemaName()); Assert.assertEquals(dbName, results.get(0).getSchema().getDbName()); Assert.assertEquals(1, results.get(0).getVersion()); Assert.assertEquals(schemaName1, results.get(1).getSchema().getSchemaName()); Assert.assertEquals(dbName, results.get(1).getSchema().getDbName()); Assert.assertEquals(2, results.get(1).getVersion()); Assert.assertEquals(schemaName2, results.get(2).getSchema().getSchemaName()); Assert.assertEquals(dbName, results.get(2).getSchema().getDbName()); Assert.assertEquals(1, results.get(2).getVersion()); Assert.assertEquals(schemaName2, results.get(3).getSchema().getSchemaName()); Assert.assertEquals(dbName, results.get(3).getSchema().getDbName()); Assert.assertEquals(2, results.get(3).getVersion()); Collections.sort(results); Assert.assertEquals(schemaName1, results.get(0).getSchema().getSchemaName());
@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(); } } }
private MSchemaVersion convertToMSchemaVersion(SchemaVersion schemaVersion) throws MetaException { return new MSchemaVersion(getMISchema( normalizeIdentifier(schemaVersion.getSchema().getCatName()), normalizeIdentifier(schemaVersion.getSchema().getDbName()), normalizeIdentifier(schemaVersion.getSchema().getSchemaName())), schemaVersion.getVersion(), schemaVersion.getCreatedAt(), createNewMColumnDescriptor(convertToMFieldSchemas(schemaVersion.getCols())), schemaVersion.isSetState() ? schemaVersion.getState().getValue() : 0, schemaVersion.isSetDescription() ? schemaVersion.getDescription() : null, schemaVersion.isSetSchemaText() ? schemaVersion.getSchemaText() : null, schemaVersion.isSetFingerprint() ? schemaVersion.getFingerprint() : null, schemaVersion.isSetName() ? schemaVersion.getName() : null, schemaVersion.isSetSerDe() ? convertToMSerDeInfo(schemaVersion.getSerDe()) : null); }
openTransaction(); String name = normalizeIdentifier(schemaName.getSchemaName()); String dbName = normalizeIdentifier(schemaName.getDbName()); String catName = normalizeIdentifier(schemaName.getCatName()); query = pm.newQuery(MSchemaVersion.class,
Assert.assertNotNull(schemaVersion); Assert.assertEquals(schemaName, schemaVersion.getSchema().getSchemaName()); Assert.assertEquals(DEFAULT_DATABASE_NAME, schemaVersion.getSchema().getDbName()); Assert.assertEquals(DEFAULT_CATALOG_NAME, schemaVersion.getSchema().getCatName()); Assert.assertEquals(version, schemaVersion.getVersion());
Assert.assertNotNull(schemaVersion); Assert.assertEquals(schemaName, schemaVersion.getSchema().getSchemaName()); Assert.assertEquals(dbName, schemaVersion.getSchema().getDbName()); Assert.assertEquals(catName, schemaVersion.getSchema().getCatName()); Assert.assertEquals(version, schemaVersion.getVersion());
Assert.assertNotNull(schemaVersion); Assert.assertEquals(schemaName, schemaVersion.getSchema().getSchemaName()); Assert.assertEquals(db.getName(), schemaVersion.getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), schemaVersion.getSchema().getCatName()); Assert.assertEquals(version, schemaVersion.getVersion());
Assert.assertNotNull(schemaVersion); Assert.assertEquals(schemaName, schemaVersion.getSchema().getSchemaName()); Assert.assertEquals(db.getName(), schemaVersion.getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), schemaVersion.getSchema().getCatName()); Assert.assertEquals(version, schemaVersion.getVersion()); Assert.assertNotNull(schemaVersion); Assert.assertEquals(schemaName, schemaVersion.getSchema().getSchemaName()); Assert.assertEquals(db.getName(), schemaVersion.getSchema().getDbName()); Assert.assertEquals(db.getCatalogName(), schemaVersion.getSchema().getCatName()); Assert.assertEquals(version, schemaVersion.getVersion());
public Object getFieldValue(_Fields field) { switch (field) { case CAT_NAME: return getCatName(); case DB_NAME: return getDbName(); case SCHEMA_NAME: return getSchemaName(); } throw new IllegalStateException(); }
@Override public ISchema getISchema(ISchemaName schemaName) throws MetaException { boolean committed = false; try { openTransaction(); ISchema schema = convertToISchema(getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName())); committed = commitTransaction(); return schema; } finally { if (!committed) { rollbackTransaction(); } } }
private MSchemaVersion convertToMSchemaVersion(SchemaVersion schemaVersion) throws MetaException { return new MSchemaVersion(getMISchema( normalizeIdentifier(schemaVersion.getSchema().getCatName()), normalizeIdentifier(schemaVersion.getSchema().getDbName()), normalizeIdentifier(schemaVersion.getSchema().getSchemaName())), schemaVersion.getVersion(), schemaVersion.getCreatedAt(), createNewMColumnDescriptor(convertToMFieldSchemas(schemaVersion.getCols())), schemaVersion.isSetState() ? schemaVersion.getState().getValue() : 0, schemaVersion.isSetDescription() ? schemaVersion.getDescription() : null, schemaVersion.isSetSchemaText() ? schemaVersion.getSchemaText() : null, schemaVersion.isSetFingerprint() ? schemaVersion.getFingerprint() : null, schemaVersion.isSetName() ? schemaVersion.getName() : null, schemaVersion.isSetSerDe() ? convertToMSerDeInfo(schemaVersion.getSerDe()) : null); }