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 7161fceaef9 [Feat](Nereids) support alter system add/drop/dropp backend command (#47951) 7161fceaef9 is described below commit 7161fceaef9b7e839c1a3d9a81a57ffef6949233 Author: Jensen <czjour...@163.com> AuthorDate: Mon Feb 17 16:04:47 2025 +0800 [Feat](Nereids) support alter system add/drop/dropp backend command (#47951) --- .../antlr4/org/apache/doris/nereids/DorisParser.g4 | 10 +-- .../main/java/org/apache/doris/alter/Alter.java | 5 ++ .../apache/doris/analysis/AddBackendClause.java | 10 +++ .../apache/doris/analysis/DropBackendClause.java | 10 +++ .../main/java/org/apache/doris/catalog/Env.java | 5 ++ .../doris/nereids/parser/LogicalPlanBuilder.java | 28 ++++++++ .../apache/doris/nereids/trees/plans/PlanType.java | 1 + .../trees/plans/commands/AlterSystemCommand.java | 80 +++++++++++++++++++++ .../trees/plans/commands/info/AddBackendOp.java} | 49 +++++++------ .../trees/plans/commands/info/AlterSystemOp.java | 57 +++++++++++++++ .../trees/plans/commands/info/BackendOp.java | 81 ++++++++++++++++++++++ .../trees/plans/commands/info/DropBackendOp.java} | 30 +++++--- 12 files changed, 329 insertions(+), 37 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 35597b45cfb..cee51ccc2ee 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 @@ -246,6 +246,10 @@ supportedAlterStatement QUOTA (quota=identifier | INTEGER_VALUE) #alterDatabaseSetQuota | ALTER SYSTEM RENAME COMPUTE GROUP name=identifier newName=identifier #alterSystemRenameComputeGroup | ALTER REPOSITORY name=identifier properties=propertyClause? #alterRepository + | ALTER SYSTEM ADD BACKEND hostPorts+=STRING_LITERAL (COMMA hostPorts+=STRING_LITERAL)* + properties=propertyClause? #addBackendClause + | ALTER SYSTEM (DROP | DROPP) BACKEND hostPorts+=STRING_LITERAL + (COMMA hostPorts+=STRING_LITERAL)* #dropBackendClause ; @@ -634,11 +638,7 @@ unsupportedAlterStatement ; alterSystemClause - : ADD BACKEND hostPorts+=STRING_LITERAL (COMMA hostPorts+=STRING_LITERAL)* - properties=propertyClause? #addBackendClause - | (DROP | DROPP) BACKEND hostPorts+=STRING_LITERAL - (COMMA hostPorts+=STRING_LITERAL)* #dropBackendClause - | DECOMMISSION BACKEND hostPorts+=STRING_LITERAL + : DECOMMISSION BACKEND hostPorts+=STRING_LITERAL (COMMA hostPorts+=STRING_LITERAL)* #decommissionBackendClause | ADD OBSERVER hostPort=STRING_LITERAL #addObserverClause | DROP OBSERVER hostPort=STRING_LITERAL #dropObserverClause diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java index 84d184c63b7..8a26c0c00ec 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java @@ -68,6 +68,7 @@ import org.apache.doris.common.util.MetaLockUtils; import org.apache.doris.common.util.PropertyAnalyzer; import org.apache.doris.common.util.PropertyAnalyzer.RewriteProperty; import org.apache.doris.datasource.ExternalTable; +import org.apache.doris.nereids.trees.plans.commands.AlterSystemCommand; import org.apache.doris.nereids.trees.plans.commands.AlterTableCommand; import org.apache.doris.nereids.trees.plans.commands.CreateMaterializedViewCommand; import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo; @@ -901,6 +902,10 @@ public class Alter { systemHandler.process(Collections.singletonList(stmt.getAlterClause()), null, null); } + public void processAlterSystem(AlterSystemCommand command) throws UserException { + systemHandler.process(Collections.singletonList(command.getAlterClause()), null, null); + } + private void processRename(Database db, OlapTable table, List<AlterClause> alterClauses) throws DdlException { for (AlterClause alterClause : alterClauses) { if (alterClause instanceof TableRenameClause) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AddBackendClause.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AddBackendClause.java index 57c3124d5ff..303fd408812 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AddBackendClause.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AddBackendClause.java @@ -21,7 +21,9 @@ import org.apache.doris.common.AnalysisException; import org.apache.doris.common.Config; import org.apache.doris.common.util.PropertyAnalyzer; import org.apache.doris.resource.Tag; +import org.apache.doris.system.SystemInfoService.HostInfo; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import lombok.Getter; @@ -45,6 +47,14 @@ public class AddBackendClause extends BackendClause { } } + public AddBackendClause(List<String> ids, List<HostInfo> hostPorts, + Map<String, String> tagMap) { + super(ImmutableList.of()); + this.ids = ids; + this.hostInfos = hostPorts; + this.tagMap = tagMap; + } + @Override public void analyze(Analyzer analyzer) throws AnalysisException { super.analyze(analyzer); diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropBackendClause.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropBackendClause.java index 34fb36afb44..3c1f80cf38a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropBackendClause.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropBackendClause.java @@ -17,6 +17,9 @@ package org.apache.doris.analysis; +import org.apache.doris.system.SystemInfoService.HostInfo; + +import com.google.common.collect.ImmutableList; import lombok.Getter; import java.util.List; @@ -35,6 +38,13 @@ public class DropBackendClause extends BackendClause { this.force = force; } + public DropBackendClause(List<String> ids, List<HostInfo> hostPorts, boolean force) { + super(ImmutableList.of()); + this.ids = ids; + this.hostInfos = hostPorts; + this.force = force; + } + @Override public String toSql() { StringBuilder sb = new StringBuilder(); 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 8fd97c21311..43cd32b3c19 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 @@ -200,6 +200,7 @@ import org.apache.doris.mysql.privilege.AccessControllerManager; import org.apache.doris.mysql.privilege.Auth; import org.apache.doris.mysql.privilege.PrivPredicate; import org.apache.doris.nereids.jobs.load.LabelProcessor; +import org.apache.doris.nereids.trees.plans.commands.AlterSystemCommand; import org.apache.doris.nereids.trees.plans.commands.AlterTableCommand; import org.apache.doris.nereids.trees.plans.commands.CreateMaterializedViewCommand; import org.apache.doris.nereids.trees.plans.commands.DropCatalogRecycleBinCommand.IdType; @@ -5698,6 +5699,10 @@ public class Env { this.alter.processAlterSystem(stmt); } + public void alterSystem(AlterSystemCommand command) throws UserException { + this.alter.processAlterSystem(command); + } + public void cancelAlterSystem(CancelAlterSystemStmt stmt) throws DdlException { this.alter.getSystemHandler().cancel(stmt); } 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 b12efea9b9a..82b886941e9 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 @@ -53,6 +53,7 @@ import org.apache.doris.mtmv.MTMVRefreshInfo; import org.apache.doris.mtmv.MTMVRefreshSchedule; import org.apache.doris.mtmv.MTMVRefreshTriggerInfo; import org.apache.doris.nereids.DorisParser; +import org.apache.doris.nereids.DorisParser.AddBackendClauseContext; import org.apache.doris.nereids.DorisParser.AddColumnClauseContext; import org.apache.doris.nereids.DorisParser.AddColumnsClauseContext; import org.apache.doris.nereids.DorisParser.AddConstraintContext; @@ -516,6 +517,7 @@ import org.apache.doris.nereids.trees.plans.commands.AlterMTMVCommand; import org.apache.doris.nereids.trees.plans.commands.AlterRoleCommand; import org.apache.doris.nereids.trees.plans.commands.AlterSqlBlockRuleCommand; import org.apache.doris.nereids.trees.plans.commands.AlterStorageVaultCommand; +import org.apache.doris.nereids.trees.plans.commands.AlterSystemCommand; import org.apache.doris.nereids.trees.plans.commands.AlterSystemRenameComputeGroupCommand; import org.apache.doris.nereids.trees.plans.commands.AlterTableCommand; import org.apache.doris.nereids.trees.plans.commands.AlterViewCommand; @@ -653,6 +655,7 @@ import org.apache.doris.nereids.trees.plans.commands.alter.AlterDatabaseRenameCo import org.apache.doris.nereids.trees.plans.commands.alter.AlterDatabaseSetQuotaCommand; import org.apache.doris.nereids.trees.plans.commands.alter.AlterRepositoryCommand; import org.apache.doris.nereids.trees.plans.commands.clean.CleanLabelCommand; +import org.apache.doris.nereids.trees.plans.commands.info.AddBackendOp; import org.apache.doris.nereids.trees.plans.commands.info.AddColumnOp; import org.apache.doris.nereids.trees.plans.commands.info.AddColumnsOp; import org.apache.doris.nereids.trees.plans.commands.info.AddPartitionOp; @@ -663,6 +666,7 @@ import org.apache.doris.nereids.trees.plans.commands.info.AlterMTMVRefreshInfo; import org.apache.doris.nereids.trees.plans.commands.info.AlterMTMVRenameInfo; import org.apache.doris.nereids.trees.plans.commands.info.AlterMTMVReplaceInfo; import org.apache.doris.nereids.trees.plans.commands.info.AlterMultiPartitionOp; +import org.apache.doris.nereids.trees.plans.commands.info.AlterSystemOp; import org.apache.doris.nereids.trees.plans.commands.info.AlterTableOp; import org.apache.doris.nereids.trees.plans.commands.info.AlterViewInfo; import org.apache.doris.nereids.trees.plans.commands.info.BuildIndexOp; @@ -680,6 +684,7 @@ import org.apache.doris.nereids.trees.plans.commands.info.CreateViewInfo; import org.apache.doris.nereids.trees.plans.commands.info.DMLCommandType; import org.apache.doris.nereids.trees.plans.commands.info.DefaultValue; import org.apache.doris.nereids.trees.plans.commands.info.DistributionDescriptor; +import org.apache.doris.nereids.trees.plans.commands.info.DropBackendOp; import org.apache.doris.nereids.trees.plans.commands.info.DropColumnOp; import org.apache.doris.nereids.trees.plans.commands.info.DropDatabaseInfo; import org.apache.doris.nereids.trees.plans.commands.info.DropIndexOp; @@ -5722,6 +5727,29 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> { return new ShowAnalyzeCommand(tableName, jobId, stateKey, stateValue, isAuto); } + @Override + public LogicalPlan visitAddBackendClause(AddBackendClauseContext ctx) { + List<String> hostPorts = ctx.hostPorts.stream() + .map(e -> stripQuotes(e.getText())) + .collect(Collectors.toList()); + Map<String, String> properties = visitPropertyClause(ctx.properties); + AlterSystemOp alterSystemOp = new AddBackendOp(hostPorts, properties); + return new AlterSystemCommand(alterSystemOp); + } + + @Override + public LogicalPlan visitDropBackendClause(DorisParser.DropBackendClauseContext ctx) { + List<String> hostPorts = ctx.hostPorts.stream() + .map(e -> stripQuotes(e.getText())) + .collect(Collectors.toList()); + boolean force = false; + if (ctx.DROPP() != null) { + force = true; + } + AlterSystemOp alterSystemOp = new DropBackendOp(hostPorts, force); + return new AlterSystemCommand(alterSystemOp); + } + @Override public LogicalPlan visitShowQueuedAnalyzeJobs(ShowQueuedAnalyzeJobsContext ctx) { List<String> tableName = ctx.tableName == null ? null : visitMultipartIdentifier(ctx.tableName); 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 31747cc49f8..6763418d72a 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 @@ -290,5 +290,6 @@ public enum PlanType { USE_COMMAND, DESCRIBE, DROP_TABLE_COMMAND, + ALTER_SYSTEM, ALTER_SYSTEM_RENAME_COMPUTE_GROUP } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterSystemCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterSystemCommand.java new file mode 100644 index 00000000000..c7290756943 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterSystemCommand.java @@ -0,0 +1,80 @@ +// 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.nereids.trees.plans.commands; + +import org.apache.doris.analysis.AlterClause; +import org.apache.doris.catalog.Env; +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.nereids.trees.plans.PlanType; +import org.apache.doris.nereids.trees.plans.commands.info.AddBackendOp; +import org.apache.doris.nereids.trees.plans.commands.info.AlterSystemOp; +import org.apache.doris.nereids.trees.plans.commands.info.DropBackendOp; +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.Preconditions; + +/** + * Alter System + */ +public class AlterSystemCommand extends Command implements ForwardWithSync { + private AlterSystemOp alterSystemOp; + + public AlterSystemCommand(AlterSystemOp alterSystemOp) { + super(PlanType.ALTER_SYSTEM); + this.alterSystemOp = alterSystemOp; + } + + /** + * getOps + */ + public AlterClause getAlterClause() { + return alterSystemOp.translateToLegacyAlterClause(); + } + + /** + * validate + */ + private void validate(ConnectContext ctx) throws UserException { + if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.OPERATOR)) { + ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, + "NODE"); + } + + Preconditions.checkState((alterSystemOp instanceof AddBackendOp + || alterSystemOp instanceof DropBackendOp) + ); + + alterSystemOp.validate(ctx); + } + + @Override + public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { + validate(ctx); + ctx.getEnv().alterSystem(this); + } + + @Override + public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { + return visitor.visitCommand(this, context); + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AddBackendClause.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AddBackendOp.java similarity index 74% copy from fe/fe-core/src/main/java/org/apache/doris/analysis/AddBackendClause.java copy to fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AddBackendOp.java index 57c3124d5ff..9352dd30bda 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AddBackendClause.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AddBackendOp.java @@ -15,39 +15,35 @@ // specific language governing permissions and limitations // under the License. -package org.apache.doris.analysis; +package org.apache.doris.nereids.trees.plans.commands.info; +import org.apache.doris.analysis.AddBackendClause; +import org.apache.doris.analysis.AlterClause; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.Config; import org.apache.doris.common.util.PropertyAnalyzer; +import org.apache.doris.qe.ConnectContext; import org.apache.doris.resource.Tag; -import com.google.common.collect.Maps; -import lombok.Getter; - import java.util.List; import java.util.Map; -public class AddBackendClause extends BackendClause { - protected Map<String, String> properties = Maps.newHashMap(); - @Getter - private Map<String, String> tagMap; +/** + * AddBackendOp + */ +public class AddBackendOp extends BackendOp { + protected final Map<String, String> properties; - public AddBackendClause(List<String> hostPorts) { - super(hostPorts); - } + private Map<String, String> tagMap; - public AddBackendClause(List<String> hostPorts, Map<String, String> properties) { + public AddBackendOp(List<String> hostPorts, Map<String, String> properties) { super(hostPorts); this.properties = properties; - if (this.properties == null) { - this.properties = Maps.newHashMap(); - } } @Override - public void analyze(Analyzer analyzer) throws AnalysisException { - super.analyze(analyzer); + public void validate(ConnectContext ctx) throws AnalysisException { + super.validate(ctx); tagMap = PropertyAnalyzer.analyzeBackendTagsProperties(properties, Tag.DEFAULT_BACKEND_TAG); if (!tagMap.containsKey(Tag.TYPE_LOCATION)) { throw new AnalysisException(NEED_LOCATION_TAG_MSG); @@ -57,11 +53,6 @@ public class AddBackendClause extends BackendClause { } } - @Override - public Map<String, String> getProperties() { - return properties; - } - @Override public String toSql() { StringBuilder sb = new StringBuilder(); @@ -75,4 +66,18 @@ public class AddBackendClause extends BackendClause { } return sb.toString(); } + + @Override + public Map<String, String> getProperties() { + return properties; + } + + @Override + public AlterClause translateToLegacyAlterClause() { + return new AddBackendClause(ids, hostInfos, tagMap); + } + + public Map<String, String> getTagMap() { + return tagMap; + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterSystemOp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterSystemOp.java new file mode 100644 index 00000000000..e93f9b18a06 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterSystemOp.java @@ -0,0 +1,57 @@ +// 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.nereids.trees.plans.commands.info; + +import org.apache.doris.alter.AlterOpType; +import org.apache.doris.analysis.AlterClause; +import org.apache.doris.common.UserException; +import org.apache.doris.qe.ConnectContext; + +import java.util.Map; + +/** + * AlterSystemOp + */ +public abstract class AlterSystemOp { + protected AlterOpType opType; + + public AlterSystemOp(AlterOpType opType) { + this.opType = opType; + } + + public AlterOpType getOpType() { + return opType; + } + + public boolean allowOpMTMV() { + return true; + } + + public boolean needChangeMTMVState() { + return false; + } + + public abstract String toSql(); + + public abstract Map<String, String> getProperties(); + + public void validate(ConnectContext ctx) throws UserException { + } + + public abstract AlterClause translateToLegacyAlterClause(); +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/BackendOp.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/BackendOp.java new file mode 100644 index 00000000000..5406ce5b73a --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/BackendOp.java @@ -0,0 +1,81 @@ +// 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.nereids.trees.plans.commands.info; + +import org.apache.doris.alter.AlterOpType; +import org.apache.doris.common.AnalysisException; +import org.apache.doris.qe.ConnectContext; +import org.apache.doris.system.SystemInfoService; +import org.apache.doris.system.SystemInfoService.HostInfo; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.NotImplementedException; + +import java.util.List; +import java.util.Map; + +/** + * BackendOp + */ +public abstract class BackendOp extends AlterSystemOp { + public static final String MUTLI_TAG_DISABLED_MSG = "Not support multi tags for Backend now. " + + "You can set 'enable_multi_tags=true' in fe.conf to enable this feature."; + public static final String NEED_LOCATION_TAG_MSG + = "Backend must have location type tag. Eg: 'tag.location' = 'xxx'."; + protected List<String> params; + + protected List<HostInfo> hostInfos; + + protected List<String> ids; + + protected BackendOp(List<String> params) { + super(AlterOpType.ALTER_OTHER); + this.params = params; + this.ids = Lists.newArrayList(); + this.hostInfos = Lists.newArrayList(); + } + + @Override + public void validate(ConnectContext ctx) throws AnalysisException { + for (String param : params) { + if (!param.contains(":")) { + ids.add(param); + } else { + HostInfo hostInfo = SystemInfoService.getHostAndPort(param); + this.hostInfos.add(hostInfo); + } + + } + Preconditions.checkState(!this.hostInfos.isEmpty() || !this.ids.isEmpty(), + "hostInfos or ids can not be empty"); + } + + @Override + public Map<String, String> getProperties() { + throw new NotImplementedException("Not support getProperties for BackendOp"); + } + + public List<HostInfo> getHostInfos() { + return hostInfos; + } + + public List<String> getIds() { + return ids; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropBackendClause.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropBackendOp.java similarity index 65% copy from fe/fe-core/src/main/java/org/apache/doris/analysis/DropBackendClause.java copy to fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropBackendOp.java index 34fb36afb44..404efca97ff 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropBackendClause.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropBackendOp.java @@ -15,24 +15,29 @@ // specific language governing permissions and limitations // under the License. -package org.apache.doris.analysis; +package org.apache.doris.nereids.trees.plans.commands.info; -import lombok.Getter; +import org.apache.doris.analysis.AlterClause; +import org.apache.doris.analysis.DropBackendClause; +import org.apache.doris.common.AnalysisException; +import org.apache.doris.qe.ConnectContext; import java.util.List; -@Getter -public class DropBackendClause extends BackendClause { +/** + * DropBackendOp + */ +public class DropBackendOp extends BackendOp { private final boolean force; - public DropBackendClause(List<String> params) { - super(params); - this.force = true; + public DropBackendOp(List<String> hostPorts, boolean force) { + super(hostPorts); + this.force = force; } - public DropBackendClause(List<String> params, boolean force) { - super(params); - this.force = force; + @Override + public void validate(ConnectContext ctx) throws AnalysisException { + super.validate(ctx); } @Override @@ -47,4 +52,9 @@ public class DropBackendClause extends BackendClause { } return sb.toString(); } + + @Override + public AlterClause translateToLegacyAlterClause() { + return new DropBackendClause(ids, hostInfos, force); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org