use of org.apache.hadoop.hive.metastore.model.MISchema in project hive by apache.
the class ObjectStore method dropISchema.
@Override
public void dropISchema(ISchemaName schemaName) throws NoSuchObjectException, MetaException {
boolean committed = false;
try {
openTransaction();
MISchema mSchema = getMISchema(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();
}
}
use of org.apache.hadoop.hive.metastore.model.MISchema in project hive by apache.
the class ObjectStore method getMISchema.
private MISchema getMISchema(String dbName, String name) {
Query query = null;
try {
name = normalizeIdentifier(name);
dbName = normalizeIdentifier(dbName);
query = pm.newQuery(MISchema.class, "name == schemaName && db.name == dbname");
query.declareParameters("java.lang.String schemaName, java.lang.String dbname");
query.setUnique(true);
MISchema mSchema = (MISchema) query.execute(name, dbName);
pm.retrieve(mSchema);
return mSchema;
} finally {
if (query != null)
query.closeAll();
}
}
use of org.apache.hadoop.hive.metastore.model.MISchema in project hive by apache.
the class ObjectStore method createISchema.
@Override
public void createISchema(ISchema schema) throws AlreadyExistsException, MetaException, NoSuchObjectException {
boolean committed = false;
MISchema mSchema = convertToMISchema(schema);
try {
openTransaction();
if (getMISchema(schema.getDbName(), schema.getName()) != null) {
throw new AlreadyExistsException("Schema with name " + schema.getDbName() + "." + schema.getName() + " already exists");
}
pm.makePersistent(mSchema);
committed = commitTransaction();
} finally {
if (!committed)
rollbackTransaction();
}
}
use of org.apache.hadoop.hive.metastore.model.MISchema in project hive by apache.
the class ObjectStore method alterISchema.
@Override
public void alterISchema(ISchemaName schemaName, ISchema newSchema) throws NoSuchObjectException, MetaException {
boolean committed = false;
try {
openTransaction();
MISchema oldMSchema = getMISchema(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();
}
}
Aggregations