Search in sources :

Example 1 with MISchema

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();
    }
}
Also used : MISchema(org.apache.hadoop.hive.metastore.model.MISchema) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException)

Example 2 with MISchema

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();
    }
}
Also used : Query(javax.jdo.Query) MISchema(org.apache.hadoop.hive.metastore.model.MISchema)

Example 3 with MISchema

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();
    }
}
Also used : AlreadyExistsException(org.apache.hadoop.hive.metastore.api.AlreadyExistsException) MISchema(org.apache.hadoop.hive.metastore.model.MISchema)

Example 4 with MISchema

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();
    }
}
Also used : MISchema(org.apache.hadoop.hive.metastore.model.MISchema) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException)

Aggregations

MISchema (org.apache.hadoop.hive.metastore.model.MISchema)4 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)2 Query (javax.jdo.Query)1 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)1