CalvinKirs commented on code in PR #36606: URL: https://github.com/apache/doris/pull/36606#discussion_r1650283550
########## fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4: ########## @@ -118,6 +118,7 @@ AUTO_INCREMENT: 'AUTO_INCREMENT'; BACKEND: 'BACKEND'; BACKENDS: 'BACKENDS'; BACKUP: 'BACKUP'; +BATCH: 'BATCH'; Review Comment: https://github.com/apache/doris/pull/36606/files#diff-19b4b34cfa5ffde0dc8660d0df94d019a848eafad24f80821e300fa62947c185R1045 I think this has already been added. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateBatchInsertJobCommand.java: ########## @@ -0,0 +1,68 @@ +// 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.catalog.Env; +import org.apache.doris.job.base.JobExecuteType; +import org.apache.doris.job.base.JobExecutionConfiguration; +import org.apache.doris.job.common.JobStatus; +import org.apache.doris.job.extensions.insert.BatchInsertJob; +import org.apache.doris.nereids.trees.plans.PlanType; +import org.apache.doris.nereids.trees.plans.commands.info.BatchInsertJobInfo; +import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; +import org.apache.doris.qe.ConnectContext; +import org.apache.doris.qe.StmtExecutor; + +/** + * Command to create a batch insert job + */ +public class CreateBatchInsertJobCommand extends Command implements ForwardWithSync, NotAllowFallback { + + private BatchInsertJobInfo batchInsertJobInfo; + + public CreateBatchInsertJobCommand(BatchInsertJobInfo batchInsertJobInfo) { + super(PlanType.CREATE_BATCH_INSERT_JOB_COMMAND); + this.batchInsertJobInfo = batchInsertJobInfo; + + } + + @Override + public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { + return visitor.visitCreateBatchInsertJobCommand(this, context); + } + + @Override + public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { + //analyze + batchInsertJobInfo.analyze(ctx, executor); + JobExecutionConfiguration jobExecutionConfiguration = new JobExecutionConfiguration(); + jobExecutionConfiguration.setExecuteType(JobExecuteType.INSTANT); + long jobId = Env.getCurrentEnv().getNextId(); Review Comment: Thank you for checking. I added a corresponding variable to indicate whether the dynamic expression was successfully replaced. If it wasn't replaced successfully, the Plan generation fails. ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindDynamicSplit.java: ########## @@ -0,0 +1,83 @@ +// 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.rules.analysis; + +import org.apache.doris.analysis.TableName; +import org.apache.doris.catalog.TableIf; +import org.apache.doris.nereids.rules.Rule; +import org.apache.doris.nereids.rules.RuleType; +import org.apache.doris.nereids.trees.expressions.GreaterThanEqual; +import org.apache.doris.nereids.trees.expressions.LessThanEqual; +import org.apache.doris.nereids.trees.expressions.Slot; +import org.apache.doris.nereids.trees.expressions.SlotReference; +import org.apache.doris.nereids.trees.expressions.literal.Literal; +import org.apache.doris.nereids.trees.plans.commands.info.SplitColumnInfo; +import org.apache.doris.nereids.trees.plans.logical.LogicalCatalogRelation; +import org.apache.doris.nereids.trees.plans.logical.LogicalDynamicSplit; +import org.apache.doris.nereids.trees.plans.logical.LogicalFilter; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import org.apache.commons.lang3.Range; + +import java.util.List; + +/** + * This class defines the rule to bind a dynamic split operation in the query plan. + */ +public class BindDynamicSplit implements AnalysisRuleFactory { + @Override + public List<Rule> buildRules() { + return ImmutableList.of( + + RuleType.BIND_DYNAMIC_SPLIT.build(logicalDynamicSplit().thenApply(ctx -> { + if (!(ctx.root.child() instanceof LogicalCatalogRelation)) { + return ctx.root; + } + + LogicalDynamicSplit logicalDynamicSplit = ctx.root; + Range range = logicalDynamicSplit.getRange(); + SplitColumnInfo splitColumnInfo = logicalDynamicSplit.getSplitColumnInfo(); + String splitColumnName = splitColumnInfo.getColumnName(); + TableName splitTable = splitColumnInfo.getTableNameInfo().transferToTableName(); + LogicalCatalogRelation catalogRelation = (LogicalCatalogRelation) ctx.root.child(); + TableIf table = catalogRelation.getTable(); + + if (!table.getName().equals(splitTable.getTbl())) { + return catalogRelation; + } + if (!table.getDatabase().getFullName().equals(splitTable.getDb())) { + return catalogRelation; + } + if (!table.getDatabase().getCatalog().getName().equals(splitTable.getCtl())) { + return catalogRelation; + } + SlotReference slotReference = null; + for (Slot slot : catalogRelation.getOutputSet()) { + if (slot.getName().equals(splitColumnName)) { Review Comment: done... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
