use of org.apache.hadoop.hive.metastore.model.MSchemaVersion in project hive by apache.
the class ObjectStore method alterSchemaVersion.
@Override
public void alterSchemaVersion(SchemaVersionDescriptor version, SchemaVersion newVersion) throws NoSuchObjectException, MetaException {
boolean committed = false;
try {
openTransaction();
MSchemaVersion oldMSchemaVersion = getMSchemaVersion(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();
}
}
use of org.apache.hadoop.hive.metastore.model.MSchemaVersion in project hive by apache.
the class ObjectStore method getAllSchemaVersion.
@Override
public List<SchemaVersion> getAllSchemaVersion(ISchemaName schemaName) throws MetaException {
boolean committed = false;
Query query = null;
try {
openTransaction();
String name = normalizeIdentifier(schemaName.getSchemaName());
String dbName = normalizeIdentifier(schemaName.getDbName());
query = pm.newQuery(MSchemaVersion.class, "iSchema.name == schemaName && iSchema.db.name == dbName");
query.declareParameters("java.lang.String schemaName, java.lang.String dbName");
query.setOrdering("version descending");
List<MSchemaVersion> mSchemaVersions = query.setParameters(name, dbName).executeList();
pm.retrieveAll(mSchemaVersions);
if (mSchemaVersions == null || mSchemaVersions.isEmpty())
return null;
List<SchemaVersion> schemaVersions = new ArrayList<>(mSchemaVersions.size());
for (MSchemaVersion mSchemaVersion : mSchemaVersions) {
pm.retrieveAll(mSchemaVersion.getCols());
if (mSchemaVersion.getSerDe() != null)
pm.retrieve(mSchemaVersion.getSerDe());
schemaVersions.add(convertToSchemaVersion(mSchemaVersion));
}
committed = commitTransaction();
return schemaVersions;
} finally {
rollbackAndCleanup(committed, query);
}
}
Aggregations