This is an automated email from the ASF dual-hosted git repository.
starocean999 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 07f2478def4 [Enhancement] (nereids) optimize CleanQueryStatsCommand
and remove CleanQueryStatsStmt (#51840)
07f2478def4 is described below
commit 07f2478def412df703e41ec9d1957867ca2a3cff
Author: yaoxiao <[email protected]>
AuthorDate: Thu Jun 19 17:22:08 2025 +0800
[Enhancement] (nereids) optimize CleanQueryStatsCommand and remove
CleanQueryStatsStmt (#51840)
---
fe/fe-core/src/main/cup/sql_parser.cup | 12 --
.../apache/doris/analysis/CleanQueryStatsStmt.java | 149 ---------------------
.../plans/commands/CleanQueryStatsCommand.java | 12 +-
.../apache/doris/persist/CleanQueryStatsInfo.java | 2 +-
.../main/java/org/apache/doris/qe/DdlExecutor.java | 22 ---
5 files changed, 4 insertions(+), 193 deletions(-)
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup
b/fe/fe-core/src/main/cup/sql_parser.cup
index 206f703e99f..1171ed1eb6d 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -1313,18 +1313,6 @@ clean_stmt ::=
{:
RESULT = new CleanProfileStmt();
:}
- | KW_CLEAN KW_QUERY KW_STATS KW_FOR ident:db
- {:
- RESULT = new CleanQueryStatsStmt(db, CleanQueryStatsStmt.Scope.DB);
- :}
- | KW_CLEAN KW_ALL KW_QUERY KW_STATS
- {:
- RESULT = new CleanQueryStatsStmt();
- :}
- | KW_CLEAN KW_QUERY KW_STATS from_or_in table_name:tbl
- {:
- RESULT = new CleanQueryStatsStmt(tbl, CleanQueryStatsStmt.Scope.TABLE);
- :}
;
// plugin statement
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CleanQueryStatsStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CleanQueryStatsStmt.java
deleted file mode 100644
index 6bf384b7c73..00000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CleanQueryStatsStmt.java
+++ /dev/null
@@ -1,149 +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.DatabaseIf;
-import org.apache.doris.catalog.Env;
-import org.apache.doris.cluster.ClusterNamespace;
-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 org.apache.commons.lang3.StringUtils;
-
-/**
- * CLEAN ALL QUERY STATS;
- * CLEAN DATABASE QUERY STATS FROM db;
- * CLEAN TABLE QUERY STATS FROM db.table;
- */
-public class CleanQueryStatsStmt extends DdlStmt implements
NotFallbackInParser {
- private String dbName;
- private TableName tableName;
- private Scope scope;
-
- /**
- * CLEAN DATABASE QUERY STATS FROM db;
- */
- public CleanQueryStatsStmt(String dbName, Scope scope) {
- this.dbName = dbName;
- this.tableName = null;
- this.scope = scope;
- }
-
- /**
- * CLEAN TABLE QUERY STATS FROM db.table;
- */
- public CleanQueryStatsStmt(TableName tableName, Scope scope) {
- this.dbName = null;
- this.tableName = tableName;
- this.scope = scope;
- }
-
- public CleanQueryStatsStmt() {
- this.scope = Scope.ALL;
- this.tableName = null;
- this.dbName = null;
- }
-
- public String getDbName() {
- return dbName;
- }
-
- public TableName getTableName() {
- return tableName;
- }
-
- public Scope getScope() {
- return scope;
- }
-
- @Override
- public void analyze(Analyzer analyzer) throws UserException {
- super.analyze(analyzer);
- switch (scope) {
- case ALL:
- if (!Env.getCurrentEnv().getAccessManager()
- .checkGlobalPriv(ConnectContext.get(),
PrivPredicate.ADMIN)) {
-
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
- "CLEAN ALL QUERY STATS");
- }
- break;
- case DB:
- if (StringUtils.isEmpty(dbName)) {
- dbName = analyzer.getDefaultDb();
- }
- if (StringUtils.isEmpty(dbName)) {
-
ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
- }
-
-
Env.getCurrentEnv().getCurrentCatalog().getDbOrAnalysisException(dbName);
- if (!Env.getCurrentEnv().getAccessManager()
- .checkDbPriv(ConnectContext.get(), tableName.getCtl(),
dbName,
- PrivPredicate.ALTER)) {
-
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
- "CLEAN DATABASE QUERY STATS FOR " +
ClusterNamespace.getNameFromFullName(dbName));
- }
- break;
- case TABLE:
- tableName.analyze(analyzer);
- dbName = tableName.getDb();
- if (StringUtils.isEmpty(dbName)) {
-
ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
- }
- DatabaseIf db =
Env.getCurrentEnv().getCurrentCatalog().getDbOrAnalysisException(dbName);
- db.getTableOrAnalysisException(tableName.getTbl());
- if (!Env.getCurrentEnv().getAccessManager()
- .checkTblPriv(ConnectContext.get(),
tableName.getCtl(), dbName, tableName.getTbl(),
- PrivPredicate.ALTER)) {
-
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
- "CLEAN TABLE QUERY STATS FROM " + tableName);
- }
- break;
- default:
- throw new IllegalStateException("Unexpected value: " + scope);
- }
- }
-
- @Override
- public String toSql() {
- switch (scope) {
- case ALL:
- return "CLEAN ALL QUERY STATS";
- case DB:
- return "CLEAN DATABASE QUERY STATS FOR " + dbName;
- case TABLE:
- return "CLEAN TABLE QUERY STATS FROM " + tableName;
- default:
- throw new IllegalStateException("Unexpected value: " + scope);
- }
- }
-
- /**
- * Scope of clean query stats
- */
- public enum Scope {
- ALL, DB, TABLE
- }
-
- @Override
- public StmtType stmtType() {
- return StmtType.CLEAN;
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CleanQueryStatsCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CleanQueryStatsCommand.java
index d8f9d8a182b..999ac608048 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CleanQueryStatsCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CleanQueryStatsCommand.java
@@ -17,7 +17,6 @@
package org.apache.doris.nereids.trees.plans.commands;
-import org.apache.doris.analysis.CleanQueryStatsStmt;
import org.apache.doris.analysis.StmtType;
import org.apache.doris.catalog.DatabaseIf;
import org.apache.doris.catalog.Env;
@@ -136,16 +135,15 @@ public class CleanQueryStatsCommand extends Command
implements ForwardWithSync {
switch (scope) {
case ALL:
cleanQueryStatsInfo = new CleanQueryStatsInfo(
- translateToLegacyScope(Scope.ALL),
env.getCurrentCatalog().getName(), null, null);
+ Scope.ALL, env.getCurrentCatalog().getName(), null,
null);
break;
case DB:
cleanQueryStatsInfo = new CleanQueryStatsInfo(
- translateToLegacyScope(Scope.DB),
env.getCurrentCatalog().getName(), tableNameInfo.getDb(), null);
+ Scope.DB, env.getCurrentCatalog().getName(),
tableNameInfo.getDb(), null);
break;
case TABLE:
cleanQueryStatsInfo = new CleanQueryStatsInfo(
- translateToLegacyScope(Scope.TABLE),
env.getCurrentCatalog().getName(), tableNameInfo.getDb(),
- tableNameInfo.getTbl());
+ Scope.TABLE, env.getCurrentCatalog().getName(),
tableNameInfo.getDb(), tableNameInfo.getTbl());
break;
default:
throw new DdlException("Unknown scope: " + scope);
@@ -165,10 +163,6 @@ public class CleanQueryStatsCommand extends Command
implements ForwardWithSync {
ALL, DB, TABLE
}
- private CleanQueryStatsStmt.Scope translateToLegacyScope(Scope scope) {
- return CleanQueryStatsStmt.Scope.valueOf(scope.name());
- }
-
@Override
public StmtType stmtType() {
return StmtType.CLEAN;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/persist/CleanQueryStatsInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/persist/CleanQueryStatsInfo.java
index d487b05b94b..98a5afd4276 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/CleanQueryStatsInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/CleanQueryStatsInfo.java
@@ -17,9 +17,9 @@
package org.apache.doris.persist;
-import org.apache.doris.analysis.CleanQueryStatsStmt.Scope;
import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;
+import
org.apache.doris.nereids.trees.plans.commands.CleanQueryStatsCommand.Scope;
import org.apache.doris.persist.gson.GsonUtils;
import com.google.gson.annotations.SerializedName;
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 cd9e4439b35..f6901b1ea53 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
@@ -57,7 +57,6 @@ import org.apache.doris.analysis.CancelJobTaskStmt;
import org.apache.doris.analysis.CancelLoadStmt;
import org.apache.doris.analysis.CleanLabelStmt;
import org.apache.doris.analysis.CleanProfileStmt;
-import org.apache.doris.analysis.CleanQueryStatsStmt;
import org.apache.doris.analysis.CopyStmt;
import org.apache.doris.analysis.CreateCatalogStmt;
import org.apache.doris.analysis.CreateDbStmt;
@@ -125,7 +124,6 @@ import org.apache.doris.load.FailMsg;
import org.apache.doris.load.loadv2.JobState;
import org.apache.doris.load.loadv2.LoadJob;
import org.apache.doris.mysql.privilege.Auth;
-import org.apache.doris.persist.CleanQueryStatsInfo;
import com.google.common.collect.Lists;
import org.apache.logging.log4j.LogManager;
@@ -347,26 +345,6 @@ public class DdlExecutor {
}
} else if (ddlStmt instanceof CleanProfileStmt) {
ProfileManager.getInstance().cleanProfile();
- } else if (ddlStmt instanceof CleanQueryStatsStmt) {
- CleanQueryStatsStmt stmt = (CleanQueryStatsStmt) ddlStmt;
- CleanQueryStatsInfo cleanQueryStatsInfo = null;
- switch (stmt.getScope()) {
- case ALL:
- cleanQueryStatsInfo = new CleanQueryStatsInfo(
- CleanQueryStatsStmt.Scope.ALL,
env.getCurrentCatalog().getName(), null, null);
- break;
- case DB:
- cleanQueryStatsInfo = new
CleanQueryStatsInfo(CleanQueryStatsStmt.Scope.DB,
- env.getCurrentCatalog().getName(),
stmt.getDbName(), null);
- break;
- case TABLE:
- cleanQueryStatsInfo = new
CleanQueryStatsInfo(CleanQueryStatsStmt.Scope.TABLE,
- env.getCurrentCatalog().getName(),
stmt.getDbName(), stmt.getTableName().getTbl());
- break;
- default:
- throw new DdlException("Unknown scope: " +
stmt.getScope());
- }
- env.cleanQueryStats(cleanQueryStatsInfo);
} else if (ddlStmt instanceof AlterRepositoryStmt) {
AlterRepositoryStmt alterRepositoryStmt = (AlterRepositoryStmt)
ddlStmt;
env.getBackupHandler().alterRepository(alterRepositoryStmt.getName(),
alterRepositoryStmt.getProperties(),
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]