use of org.apache.hadoop.hive.metastore.model.MFunction in project hive by apache.
the class ObjectStore method alterFunction.
@Override
public void alterFunction(String dbName, String funcName, Function newFunction) throws InvalidObjectException, MetaException {
boolean success = false;
try {
openTransaction();
funcName = HiveStringUtils.normalizeIdentifier(funcName);
dbName = HiveStringUtils.normalizeIdentifier(dbName);
MFunction newf = convertToMFunction(newFunction);
if (newf == null) {
throw new InvalidObjectException("new function is invalid");
}
MFunction oldf = getMFunction(dbName, funcName);
if (oldf == null) {
throw new MetaException("function " + funcName + " doesn't exist");
}
// For now only alter name, owner, class name, type
oldf.setFunctionName(HiveStringUtils.normalizeIdentifier(newf.getFunctionName()));
oldf.setDatabase(newf.getDatabase());
oldf.setOwnerName(newf.getOwnerName());
oldf.setOwnerType(newf.getOwnerType());
oldf.setClassName(newf.getClassName());
oldf.setFunctionType(newf.getFunctionType());
// commit the changes
success = commitTransaction();
} finally {
if (!success) {
rollbackTransaction();
}
}
}
use of org.apache.hadoop.hive.metastore.model.MFunction in project hive by apache.
the class ObjectStore method getAllFunctions.
@Override
public List<Function> getAllFunctions() throws MetaException {
boolean commited = false;
try {
openTransaction();
Query query = pm.newQuery(MFunction.class);
List<MFunction> allFunctions = (List<MFunction>) query.execute();
pm.retrieveAll(allFunctions);
commited = commitTransaction();
return convertToFunctions(allFunctions);
} finally {
if (!commited) {
rollbackTransaction();
}
}
}
use of org.apache.hadoop.hive.metastore.model.MFunction in project hive by apache.
the class ObjectStore method convertToMFunction.
private MFunction convertToMFunction(Function func) throws InvalidObjectException {
if (func == null) {
return null;
}
MDatabase mdb = null;
try {
mdb = getMDatabase(func.getDbName());
} catch (NoSuchObjectException e) {
LOG.error(StringUtils.stringifyException(e));
throw new InvalidObjectException("Database " + func.getDbName() + " doesn't exist.");
}
MFunction mfunc = new MFunction(func.getFunctionName(), mdb, func.getClassName(), func.getOwnerName(), func.getOwnerType().name(), func.getCreateTime(), func.getFunctionType().getValue(), convertToMResourceUriList(func.getResourceUris()));
return mfunc;
}
use of org.apache.hadoop.hive.metastore.model.MFunction in project hive by apache.
the class ObjectStore method dropFunction.
@Override
public void dropFunction(String dbName, String funcName) throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException {
boolean success = false;
try {
openTransaction();
MFunction mfunc = getMFunction(dbName, funcName);
pm.retrieve(mfunc);
if (mfunc != null) {
// TODO: When function privileges are implemented, they should be deleted here.
pm.deletePersistentAll(mfunc);
}
success = commitTransaction();
} finally {
if (!success) {
rollbackTransaction();
}
}
}
use of org.apache.hadoop.hive.metastore.model.MFunction in project hive by apache.
the class ObjectStore method createFunction.
@Override
public void createFunction(Function func) throws InvalidObjectException, MetaException {
boolean committed = false;
try {
openTransaction();
MFunction mfunc = convertToMFunction(func);
pm.makePersistent(mfunc);
committed = commitTransaction();
} finally {
if (!committed) {
rollbackTransaction();
}
}
}
Aggregations