diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup index c6d974b2ee83f4..4df912fbf9f46e 100644 --- a/fe/fe-core/src/main/cup/sql_parser.cup +++ b/fe/fe-core/src/main/cup/sql_parser.cup @@ -2571,11 +2571,6 @@ drop_stmt ::= {: RESULT = new DropCatalogStmt(ifExists, catalogName); :} - /* Function */ - | KW_DROP opt_var_type:type KW_FUNCTION opt_if_exists:ifExists function_name:functionName LPAREN func_args_def:args RPAREN - {: - RESULT = new DropFunctionStmt(type, ifExists, functionName, args); - :} /* Table */ | KW_DROP KW_TABLE opt_if_exists:ifExists table_name:name opt_force:force {: diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropFunctionStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropFunctionStmt.java deleted file mode 100644 index c91cffdcf35ad1..00000000000000 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropFunctionStmt.java +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.apache.doris.analysis; - -import org.apache.doris.catalog.Env; -import org.apache.doris.catalog.FunctionSearchDesc; -import org.apache.doris.common.ErrorCode; -import org.apache.doris.common.ErrorReport; -import org.apache.doris.common.UserException; -import org.apache.doris.mysql.privilege.PrivPredicate; -import org.apache.doris.qe.ConnectContext; - -import com.google.common.base.Joiner; - -public class DropFunctionStmt extends DdlStmt implements NotFallbackInParser { - private final boolean ifExists; - private final FunctionName functionName; - private final FunctionArgsDef argsDef; - private SetType type = SetType.DEFAULT; - - // set after analyzed - private FunctionSearchDesc function; - - public DropFunctionStmt(SetType type, boolean ifExists, FunctionName functionName, FunctionArgsDef argsDef) { - this.type = type; - this.ifExists = ifExists; - this.functionName = functionName; - this.argsDef = argsDef; - } - - public SetType getType() { - return type; - } - - public boolean isIfExists() { - return ifExists; - } - - public FunctionName getFunctionName() { - return functionName; - } - - public FunctionSearchDesc getFunction() { - return function; - } - - @Override - public void analyze() throws UserException { - super.analyze(); - // check operation privilege - if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) { - ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ADMIN"); - } - - // analyze arguments - function = new FunctionSearchDesc(functionName, argsDef.getArgTypes(), argsDef.isVariadic()); - } - - @Override - public String toSql() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("DROP FUNCTION ").append(functionName).append(argsDef); - return stringBuilder.toString(); - } - - public String signatureString() { - StringBuilder sb = new StringBuilder(); - sb.append(functionName.getFunction()).append("(").append(Joiner.on(", ").join(argsDef.getArgTypes())); - sb.append(")"); - return sb.toString(); - } - - @Override - public RedirectStatus getRedirectStatus() { - return RedirectStatus.FORWARD_WITH_SYNC; - } - - @Override - public StmtType stmtType() { - return StmtType.DROP; - } -} diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index 9cc3a6488c8764..d895d4e35b05c6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -35,11 +35,9 @@ import org.apache.doris.analysis.CreateTableStmt; import org.apache.doris.analysis.DdlStmt; import org.apache.doris.analysis.DistributionDesc; -import org.apache.doris.analysis.DropFunctionStmt; import org.apache.doris.analysis.DropPartitionClause; import org.apache.doris.analysis.DropTableStmt; import org.apache.doris.analysis.Expr; -import org.apache.doris.analysis.FunctionName; import org.apache.doris.analysis.InstallPluginStmt; import org.apache.doris.analysis.ModifyDistributionClause; import org.apache.doris.analysis.PartitionRenameClause; @@ -48,7 +46,6 @@ import org.apache.doris.analysis.RecoverTableStmt; import org.apache.doris.analysis.ReplacePartitionClause; import org.apache.doris.analysis.RollupRenameClause; -import org.apache.doris.analysis.SetType; import org.apache.doris.analysis.SlotRef; import org.apache.doris.analysis.TableRenameClause; import org.apache.doris.analysis.UninstallPluginStmt; @@ -274,14 +271,12 @@ import org.apache.doris.statistics.StatisticsCleaner; import org.apache.doris.statistics.StatisticsJobAppender; import org.apache.doris.statistics.query.QueryStats; -import org.apache.doris.system.Backend; import org.apache.doris.system.Frontend; import org.apache.doris.system.HeartbeatMgr; import org.apache.doris.system.SystemInfoService; import org.apache.doris.system.SystemInfoService.HostInfo; import org.apache.doris.task.AgentBatchTask; import org.apache.doris.task.AgentTaskExecutor; -import org.apache.doris.task.CleanUDFCacheTask; import org.apache.doris.task.CompactionTask; import org.apache.doris.task.MasterTaskExecutor; import org.apache.doris.task.PriorityMasterTaskExecutor; @@ -6571,17 +6566,6 @@ public void replayCreateGlobalFunction(Function function) { globalFunctionMgr.replayAddFunction(function); } - public void dropFunction(DropFunctionStmt stmt) throws UserException { - FunctionName name = stmt.getFunctionName(); - if (SetType.GLOBAL.equals(stmt.getType())) { - globalFunctionMgr.dropFunction(stmt.getFunction(), stmt.isIfExists()); - } else { - Database db = getInternalCatalog().getDbOrDdlException(name.getDb()); - db.dropFunction(stmt.getFunction(), stmt.isIfExists()); - } - cleanUDFCacheTask(stmt); // BE will cache classload, when drop function, BE need clear cache - } - public void replayDropFunction(FunctionSearchDesc functionSearchDesc) throws MetaNotFoundException { String dbName = functionSearchDesc.getName().getDb(); Database db = getInternalCatalog().getDbOrMetaException(dbName); @@ -7090,18 +7074,6 @@ public void onErasePartition(Partition partition) { getInternalCatalog().erasePartitionDropBackendReplicas(Lists.newArrayList(partition)); } - public void cleanUDFCacheTask(DropFunctionStmt stmt) throws UserException { - ImmutableMap backendsInfo = Env.getCurrentSystemInfo().getAllBackendsByAllCluster(); - String functionSignature = stmt.signatureString(); - AgentBatchTask batchTask = new AgentBatchTask(); - for (Backend backend : backendsInfo.values()) { - CleanUDFCacheTask cleanUDFCacheTask = new CleanUDFCacheTask(backend.getId(), functionSignature); - batchTask.addTask(cleanUDFCacheTask); - LOG.info("clean udf cache in be {}, beId {}", backend.getHost(), backend.getId()); - } - AgentTaskExecutor.submit(batchTask); - } - public void setPartitionVersion(AdminSetPartitionVersionStmt stmt) throws DdlException { String database = stmt.getDatabase(); String table = stmt.getTable(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java index c613c6d41ebaff..3f5dd05d9b6af2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java @@ -40,7 +40,6 @@ import org.apache.doris.analysis.CreateWorkloadSchedPolicyStmt; import org.apache.doris.analysis.DdlStmt; import org.apache.doris.analysis.DropCatalogStmt; -import org.apache.doris.analysis.DropFunctionStmt; import org.apache.doris.analysis.DropIndexPolicyStmt; import org.apache.doris.analysis.DropRepositoryStmt; import org.apache.doris.analysis.DropSqlBlockRuleStmt; @@ -87,9 +86,7 @@ public class DdlExecutor { **/ public static void execute(Env env, DdlStmt ddlStmt) throws Exception { checkDdlStmtSupported(ddlStmt); - if (ddlStmt instanceof DropFunctionStmt) { - env.dropFunction((DropFunctionStmt) ddlStmt); - } else if (ddlStmt instanceof CreateEncryptKeyStmt) { + if (ddlStmt instanceof CreateEncryptKeyStmt) { EncryptKeyHelper.createEncryptKey((CreateEncryptKeyStmt) ddlStmt); } else if (ddlStmt instanceof CreateTableStmt) { env.createTable((CreateTableStmt) ddlStmt);