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 0b718e863c8 [Enhancement] (nereids)implement DropRepositoryCommand in
nereids (#45004)
0b718e863c8 is described below
commit 0b718e863c8ec07d7d2351ea22e7a983947dded6
Author: Vallish Pai <[email protected]>
AuthorDate: Fri Dec 6 12:52:42 2024 +0530
[Enhancement] (nereids)implement DropRepositoryCommand in nereids (#45004)
Issue Number: close #42617
---
.../antlr4/org/apache/doris/nereids/DorisParser.g4 | 3 +-
.../org/apache/doris/backup/BackupHandler.java | 7 ++++-
.../doris/nereids/parser/LogicalPlanBuilder.java | 7 +++++
.../apache/doris/nereids/trees/plans/PlanType.java | 1 +
.../trees/plans/commands/AlterRoleCommand.java | 3 --
...RoleCommand.java => DropRepositoryCommand.java} | 36 ++++++++++++----------
.../trees/plans/commands/ShowGrantsCommand.java | 3 --
.../plans/commands/ShowPartitionIdCommand.java | 3 --
.../trees/plans/commands/ShowProcCommand.java | 4 ---
.../trees/plans/commands/ShowRolesCommand.java | 4 ---
.../trees/plans/commands/ShowTableIdCommand.java | 3 --
.../trees/plans/visitor/CommandVisitor.java | 13 +++++---
.../repository/show_repositories_command.groovy | 2 +-
13 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index fd40e2c1400..f229a1b2f4a 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -216,6 +216,8 @@ supportedDropStatement
| DROP FILE name=STRING_LITERAL
((FROM | IN) database=identifier)? properties=propertyClause
#dropFile
| DROP WORKLOAD POLICY (IF EXISTS)? name=identifierOrText
#dropWorkloadPolicy
+ | DROP REPOSITORY name=identifier
#dropRepository
+
;
supportedShowStatement
@@ -684,7 +686,6 @@ unsupportedDropStatement
functionIdentifier LEFT_PAREN functionArguments? RIGHT_PAREN
#dropFunction
| DROP TABLE (IF EXISTS)? name=multipartIdentifier FORCE?
#dropTable
| DROP VIEW (IF EXISTS)? name=multipartIdentifier
#dropView
- | DROP REPOSITORY name=identifier
#dropRepository
| DROP INDEX (IF EXISTS)? name=identifier ON tableName=multipartIdentifier
#dropIndex
| DROP RESOURCE (IF EXISTS)? name=identifierOrText
#dropResource
| DROP ROW POLICY (IF EXISTS)? policyName=identifier
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
index d70544add98..6a12eee3a78 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
@@ -281,9 +281,14 @@ public class BackupHandler extends MasterDaemon implements
Writable {
// handle drop repository stmt
public void dropRepository(DropRepositoryStmt stmt) throws DdlException {
+ dropRepository(stmt.getRepoName());
+ }
+
+ // handle drop repository stmt
+ public void dropRepository(String repoName) throws DdlException {
tryLock();
try {
- Repository repo = repoMgr.getRepo(stmt.getRepoName());
+ Repository repo = repoMgr.getRepo(repoName);
if (repo == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
"Repository does not exist");
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 9ed352b65e5..71ea972c4ab 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -118,6 +118,7 @@ import
org.apache.doris.nereids.DorisParser.DropEncryptkeyContext;
import org.apache.doris.nereids.DorisParser.DropFileContext;
import org.apache.doris.nereids.DorisParser.DropMTMVContext;
import org.apache.doris.nereids.DorisParser.DropProcedureContext;
+import org.apache.doris.nereids.DorisParser.DropRepositoryContext;
import org.apache.doris.nereids.DorisParser.DropRoleContext;
import org.apache.doris.nereids.DorisParser.DropSqlBlockRuleContext;
import org.apache.doris.nereids.DorisParser.DropUserContext;
@@ -508,6 +509,7 @@ import
org.apache.doris.nereids.trees.plans.commands.DropFileCommand;
import org.apache.doris.nereids.trees.plans.commands.DropJobCommand;
import org.apache.doris.nereids.trees.plans.commands.DropMTMVCommand;
import org.apache.doris.nereids.trees.plans.commands.DropProcedureCommand;
+import org.apache.doris.nereids.trees.plans.commands.DropRepositoryCommand;
import org.apache.doris.nereids.trees.plans.commands.DropRoleCommand;
import org.apache.doris.nereids.trees.plans.commands.DropSqlBlockRuleCommand;
import org.apache.doris.nereids.trees.plans.commands.DropUserCommand;
@@ -4867,6 +4869,11 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
return new DropFileCommand(stripQuotes(ctx.name.getText()), dbName,
properties);
}
+ @Override
+ public LogicalPlan visitDropRepository(DropRepositoryContext ctx) {
+ return new DropRepositoryCommand(stripQuotes(ctx.name.getText()));
+ }
+
@Override
public LogicalPlan visitDropSqlBlockRule(DropSqlBlockRuleContext ctx) {
return new
DropSqlBlockRuleCommand(visitIdentifierSeq(ctx.identifierSeq()), ctx.EXISTS()
!= null);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java
index aaa93d70c35..bc8ccf83093 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java
@@ -168,6 +168,7 @@ public enum PlanType {
CREATE_PROCEDURE_COMMAND,
DROP_PROCEDURE_COMMAND,
DROP_ROLE_COMMAND,
+ DROP_REPOSITOORY_COMMAND,
SHOW_PROCEDURE_COMMAND,
SHOW_CREATE_PROCEDURE_COMMAND,
CREATE_VIEW_COMMAND,
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoleCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoleCommand.java
index fe8d0fd5db9..9f2d4ba2274 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoleCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoleCommand.java
@@ -27,14 +27,11 @@ import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.StmtExecutor;
import com.google.common.base.Strings;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
/**
* alter role command
*/
public class AlterRoleCommand extends AlterCommand {
- public static final Logger LOG =
LogManager.getLogger(AlterRoleCommand.class);
private final String role;
private final String comment;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoleCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropRepositoryCommand.java
similarity index 66%
copy from
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoleCommand.java
copy to
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropRepositoryCommand.java
index fe8d0fd5db9..4fef49c3993 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterRoleCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropRepositoryCommand.java
@@ -18,6 +18,7 @@
package org.apache.doris.nereids.trees.plans.commands;
import org.apache.doris.catalog.Env;
+import org.apache.doris.common.DdlException;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.mysql.privilege.PrivPredicate;
@@ -26,40 +27,41 @@ import
org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.StmtExecutor;
-import com.google.common.base.Strings;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
- * alter role command
+ * drop repository command
*/
-public class AlterRoleCommand extends AlterCommand {
- public static final Logger LOG =
LogManager.getLogger(AlterRoleCommand.class);
- private final String role;
- private final String comment;
+public class DropRepositoryCommand extends DropCommand {
+ public static final Logger LOG =
LogManager.getLogger(DropRepositoryCommand.class);
+ private final String repoName;
/**
* constructor
*/
-
- public AlterRoleCommand(String role, String comment) {
- super(PlanType.ALTER_ROLE_COMMAND);
- this.role = role;
- this.comment = Strings.nullToEmpty(comment);
-
+ public DropRepositoryCommand(String repoName) {
+ super(PlanType.DROP_REPOSITOORY_COMMAND);
+ this.repoName = repoName;
}
@Override
public void doRun(ConnectContext ctx, StmtExecutor executor) throws
Exception {
- // check if current user has GRANT priv on GLOBAL level.
- if
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(),
PrivPredicate.GRANT)) {
-
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
"ALTER ROLE");
+ // check auth
+ if
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(),
PrivPredicate.ADMIN)) {
+
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
"ADMIN");
}
- Env.getCurrentEnv().getAuth().alterRole(role, comment);
+ Env.getCurrentEnv().getBackupHandler().dropRepository(repoName);
}
@Override
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
- return visitor.visitAlterRoleCommand(this, context);
+ return visitor.visitDropRepositoryCommand(this, context);
+ }
+
+ @Override
+ protected void checkSupportedInCloudMode(ConnectContext ctx) throws
DdlException {
+ LOG.info("DropRepositoryCommand not supported in cloud mode");
+ throw new DdlException("Unsupported operation");
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowGrantsCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowGrantsCommand.java
index f877f42b835..6d52d374fa7 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowGrantsCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowGrantsCommand.java
@@ -34,8 +34,6 @@ import org.apache.doris.qe.ShowResultSetMetaData;
import org.apache.doris.qe.StmtExecutor;
import com.google.common.base.Preconditions;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.util.List;
@@ -43,7 +41,6 @@ import java.util.List;
* show grants command
*/
public class ShowGrantsCommand extends ShowCommand {
- public static final Logger LOG =
LogManager.getLogger(ShowGrantsCommand.class);
private static final ShowResultSetMetaData META_DATA;
private final boolean isAll;
private UserIdentity userIdent; // if not given will update with self.
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowPartitionIdCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowPartitionIdCommand.java
index fb7e5cdf968..47977a8e896 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowPartitionIdCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowPartitionIdCommand.java
@@ -35,8 +35,6 @@ import org.apache.doris.qe.ShowResultSetMetaData;
import org.apache.doris.qe.StmtExecutor;
import com.google.common.collect.Lists;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@@ -45,7 +43,6 @@ import java.util.List;
* show partition command
*/
public class ShowPartitionIdCommand extends ShowCommand {
- public static final Logger LOG =
LogManager.getLogger(ShowPartitionIdCommand.class);
private final long partitionId;
/**
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowProcCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowProcCommand.java
index da2fb38c4d8..fc865a07457 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowProcCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowProcCommand.java
@@ -35,16 +35,12 @@ import org.apache.doris.qe.ShowResultSet;
import org.apache.doris.qe.ShowResultSetMetaData;
import org.apache.doris.qe.StmtExecutor;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
import java.util.List;
/**
* show proc command
*/
public class ShowProcCommand extends ShowCommand {
- public static final Logger LOG =
LogManager.getLogger(ShowProcCommand.class);
private final String path;
/**
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowRolesCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowRolesCommand.java
index 7cbb5f934ca..4ca4c051cdb 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowRolesCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowRolesCommand.java
@@ -30,16 +30,12 @@ import org.apache.doris.qe.ShowResultSet;
import org.apache.doris.qe.ShowResultSetMetaData;
import org.apache.doris.qe.StmtExecutor;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
import java.util.List;
/**
* show roles command
*/
public class ShowRolesCommand extends ShowCommand {
- public static final Logger LOG =
LogManager.getLogger(ShowRolesCommand.class);
private static final ShowResultSetMetaData META_DATA;
static {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableIdCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableIdCommand.java
index 3acd6c7992c..59e1834215a 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableIdCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableIdCommand.java
@@ -33,8 +33,6 @@ import org.apache.doris.qe.ShowResultSetMetaData;
import org.apache.doris.qe.StmtExecutor;
import com.google.common.collect.Lists;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@@ -43,7 +41,6 @@ import java.util.List;
* show table id command
*/
public class ShowTableIdCommand extends ShowCommand {
- public static final Logger LOG =
LogManager.getLogger(ShowTableIdCommand.class);
private final long tableId;
/**
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
index 339bb4e4c6a..77846ff3ad5 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
@@ -55,6 +55,7 @@ import
org.apache.doris.nereids.trees.plans.commands.DropFileCommand;
import org.apache.doris.nereids.trees.plans.commands.DropJobCommand;
import org.apache.doris.nereids.trees.plans.commands.DropMTMVCommand;
import org.apache.doris.nereids.trees.plans.commands.DropProcedureCommand;
+import org.apache.doris.nereids.trees.plans.commands.DropRepositoryCommand;
import org.apache.doris.nereids.trees.plans.commands.DropRoleCommand;
import org.apache.doris.nereids.trees.plans.commands.DropSqlBlockRuleCommand;
import org.apache.doris.nereids.trees.plans.commands.DropUserCommand;
@@ -506,12 +507,16 @@ public interface CommandVisitor<R, C> {
return visitCommand(showLoadProfileCommand, context);
}
- default R visitAlterSqlBlockRuleCommand(AlterSqlBlockRuleCommand
dropRoleCommand, C context) {
- return visitCommand(dropRoleCommand, context);
+ default R visitAlterSqlBlockRuleCommand(AlterSqlBlockRuleCommand cmd, C
context) {
+ return visitCommand(cmd, context);
}
- default R visitCreateSqlBlockRuleCommand(CreateSqlBlockRuleCommand
dropRoleCommand, C context) {
- return visitCommand(dropRoleCommand, context);
+ default R visitCreateSqlBlockRuleCommand(CreateSqlBlockRuleCommand cmd, C
context) {
+ return visitCommand(cmd, context);
+ }
+
+ default R visitDropRepositoryCommand(DropRepositoryCommand cmd, C context)
{
+ return visitCommand(cmd, context);
}
default R visitCreateRoleCommand(CreateRoleCommand createRoleCommand, C
context) {
diff --git
a/regression-test/suites/nereids_p0/ddl/repository/show_repositories_command.groovy
b/regression-test/suites/nereids_p0/ddl/repository/show_repositories_command.groovy
index 43fadf3b1a8..5d352010900 100644
---
a/regression-test/suites/nereids_p0/ddl/repository/show_repositories_command.groovy
+++
b/regression-test/suites/nereids_p0/ddl/repository/show_repositories_command.groovy
@@ -47,7 +47,7 @@ suite("show_repositories_command") {
def show_repo = checkNereidsExecuteWithResult("""SHOW
REPOSITORIES;""").toString();
assertTrue(show_repo.contains("${repoName}"))
- sql """DROP REPOSITORY `${repoName}`;"""
+ checkNereidsExecute("DROP REPOSITORY `${repoName}`;")
def show_repo_after_drop = checkNereidsExecuteWithResult("""SHOW
REPOSITORIES;""").toString();
assertFalse(show_repo_after_drop.contains("${repoName}"))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]