public void unregisterFunction(String functionName) throws HiveException { lock.lock(); try { functionName = functionName.toLowerCase(); FunctionInfo fi = mFunctions.get(functionName); if (fi != null) { if (fi.isBuiltIn()) { throw new HiveException(ErrorMsg.DROP_NATIVE_FUNCTION.getMsg(functionName)); } mFunctions.remove(functionName); fi.discarded(); if (fi.isPersistent()) { removePersistentFunctionUnderLock(fi); } } } finally { lock.unlock(); } }
public void unregisterFunction(String functionName) throws HiveException { lock.lock(); try { functionName = functionName.toLowerCase(); FunctionInfo fi = mFunctions.get(functionName); if (fi != null) { if (fi.isBuiltIn()) { throw new HiveException(ErrorMsg.DROP_NATIVE_FUNCTION.getMsg(functionName)); } mFunctions.remove(functionName); fi.discarded(); if (fi.isPersistent()) { removePersistentFunctionUnderLock(fi); } } } finally { lock.unlock(); } }
public void testBuiltInFunction() throws Exception { FunctionInfo functionInfo = FunctionRegistry.getFunctionInfo("ln"); assertTrue(functionInfo.isBuiltIn()); assertTrue(functionInfo.isNative()); }
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 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); rootTasks.add(TaskFactory.get(new FunctionWork(desc), conf)); addEntities(functionName, isTemporaryFunction, null); }
assertTrue(functionInfo.isPersistent()); assertTrue(functionInfo.isNative()); assertFalse(functionInfo.isBuiltIn()); functionInfo = FunctionRegistry.getFunctionInfo("default.perm_ln"); assertTrue(functionInfo.isPersistent()); assertTrue(functionInfo.isNative()); assertFalse(functionInfo.isBuiltIn()); assertTrue(functionInfo.isPersistent()); assertTrue(functionInfo.isNative()); assertFalse(functionInfo.isBuiltIn()); assertTrue(functionInfo.isPersistent()); assertTrue(functionInfo.isNative()); assertFalse(functionInfo.isBuiltIn()); assertTrue(functionInfo.isPersistent()); assertTrue(functionInfo.isNative()); assertFalse(functionInfo.isBuiltIn());
public synchronized void unregisterFunction(String functionName) throws HiveException { functionName = functionName.toLowerCase(); FunctionInfo fi = mFunctions.get(functionName); if (fi != null) { if (fi.isBuiltIn()) { throw new HiveException(ErrorMsg.DROP_NATIVE_FUNCTION.getMsg(functionName)); } mFunctions.remove(functionName); fi.discarded(); } }
private synchronized void addFunction(String functionName, FunctionInfo function) { if (isNative ^ function.isNative()) { throw new RuntimeException("Function " + functionName + " is not for this registry"); } functionName = functionName.toLowerCase(); FunctionInfo prev = mFunctions.get(functionName); if (prev != null) { if (isBuiltInFunc(prev.getFunctionClass())) { throw new RuntimeException("Function " + functionName + " is hive builtin function, " + "which cannot be overriden."); } prev.discarded(); } mFunctions.put(functionName, function); if (function.isBuiltIn()) { builtIns.add(function.getFunctionClass()); } }
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); rootTasks.add(TaskFactory.get(new FunctionWork(desc), conf)); addEntities(functionName, isTemporaryFunction, null); }