private Class<?> getPermanentUdfClass(FunctionInfo function) { Class<?> functionClass = function.getFunctionClass(); if (functionClass == null) { // Expected for permanent UDFs at this point. ClassLoader loader = Utilities.getSessionSpecifiedClassLoader(); try { functionClass = Class.forName(function.getClassName(), true, loader); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } } return functionClass; }
private Class<?> getPermanentUdfClass(FunctionInfo function) { Class<?> functionClass = function.getFunctionClass(); if (functionClass == null) { // Expected for permanent UDFs at this point. ClassLoader loader = Utilities.getSessionSpecifiedClassLoader(); try { functionClass = Class.forName(function.getClassName(), true, loader); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } } return functionClass; }
private static ReadEntity createReadEntity(String functionName, FunctionInfo functionInfo) throws HiveException { String[] qualFunctionName = FunctionUtils.getQualifiedFunctionNameParts(functionName); // this is only for the purpose of authorization, only the name matters. Database db = new Database(qualFunctionName[0], "", "", null); return new ReadEntity(db, qualFunctionName[1], functionInfo.getClassName(), Type.FUNCTION); }
Class<?> udfClass = Class.forName(function.getClassName(), true, loader); qualifiedName, FunctionType.PERSISTENT, udfClass, resources); if (ret == null) { LOG.error(function.getClassName() + " is not a valid UDF class and was not registered.");
Class<?> udfClass = Class.forName(function.getClassName(), true, loader); qualifiedName, FunctionType.PERSISTENT, udfClass, resources); if (ret == null) { LOG.error(function.getClassName() + " is not a valid UDF class and was not registered.");
private void analyzeDropFunction(ASTNode ast) throws SemanticException { // ^(TOK_DROPFUNCTION identifier ifExists? $temp?) String functionName = ast.getChild(0).getText(); boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null); // we want to signal an error if the function doesn't exist and we're // configured not to ignore this boolean throwException = !ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT); FunctionInfo info = FunctionRegistry.getFunctionInfo(functionName); if (info == null) { if (throwException) { throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(functionName)); } else { // Fail silently return; } } else if (info.isBuiltIn()) { throw new SemanticException(ErrorMsg.DROP_NATIVE_FUNCTION.getMsg(functionName)); } boolean isTemporaryFunction = (ast.getFirstChildWithType(HiveParser.TOK_TEMPORARY) != null); DropFunctionDesc desc = new DropFunctionDesc(functionName, isTemporaryFunction, null); rootTasks.add(TaskFactory.get(new FunctionWork(desc))); addEntities(functionName, info.getClassName(), isTemporaryFunction, null); }
private FunctionInfo registerToSessionRegistry(String qualifiedName, FunctionInfo function) { FunctionInfo ret = null; ClassLoader prev = Utilities.getSessionSpecifiedClassLoader(); try { // Found UDF in metastore - now add it to the function registry // At this point we should add any relevant jars that would be needed for the UDf. FunctionResource[] resources = function.getResources(); try { FunctionTask.addFunctionResources(resources); } catch (Exception e) { LOG.error("Unable to load resources for " + qualifiedName + ":" + e, e); return null; } ClassLoader loader = Utilities.getSessionSpecifiedClassLoader(); Class<?> udfClass = Class.forName(function.getClassName(), true, loader); ret = FunctionRegistry.registerTemporaryUDF(qualifiedName, udfClass, resources); if (ret == null) { LOG.error(function.getClassName() + " is not a valid UDF class and was not registered."); } if (SessionState.get().isHiveServerQuery()) { SessionState.getRegistryForWrite().addToUDFLoaders(loader); } } catch (ClassNotFoundException e) { // Lookup of UDf class failed LOG.error("Unable to load UDF class: " + e); Utilities.restoreSessionSpecifiedClassLoader(prev); } function.shareStateWith(ret); return ret; }