This is an automated email from the ASF dual-hosted git repository. zhangstar333 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 3a7fab486cd [Bug](drop) fix drop function has error when it's not exists (#35878) 3a7fab486cd is described below commit 3a7fab486cd4c2f61ee401960d858bf60fe3883b Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com> AuthorDate: Thu Jun 13 15:30:05 2024 +0800 [Bug](drop) fix drop function has error when it's not exists (#35878) ## Proposed changes ``` drop function xxx drop function if exists xxx ``` as when drop UDTF function, we need drop two function, one is normal, another is the _outer function. getFunction() should call firstly and always. as dropFunctionImpl() will remove it from env, then we can't find it anymore. so can't check if (ifExists) firstly, when it's false, we have no change call getFunction() ifExists should only used to check whether throw execption. Issue Number: close #xxx <!--Describe your changes.--> --- .../src/main/java/org/apache/doris/catalog/Database.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java index 2e29fdf9037..0fab32a4924 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java @@ -748,14 +748,18 @@ public class Database extends MetaObject implements Writable, DatabaseIf<Table> public synchronized void dropFunction(FunctionSearchDesc function, boolean ifExists) throws UserException { Function udfFunction = null; - if (ifExists) { - try { - // here we must first getFunction, as dropFunctionImpl will remove it - udfFunction = getFunction(function); - } catch (AnalysisException e) { + try { + // here we must first getFunction, as dropFunctionImpl will remove it + udfFunction = getFunction(function); + } catch (AnalysisException e) { + if (!ifExists) { + throw new UserException(e); + } else { // ignore it, as drop it if exist, so can't sure it must exist + return; } } + dropFunctionImpl(function, ifExists); if (udfFunction != null && udfFunction.isUDTFunction()) { // all of the table function in doris will have two function --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org