From 0a385465960c86508af5cf445154a2b4e3505f38 Mon Sep 17 00:00:00 2001 From: morrySnow <101034200+morrySnow@users.noreply.github.com> Date: Thu, 12 Oct 2023 19:20:59 +0800 Subject: [PATCH] [opt](Nereids) reject group commit insert temporarily (#25359) group commit insert introduced by PR #22829. since nereids has not support it, we forbid it temporarily on Nereids until impl it. --- .../doris/nereids/jobs/executor/Rewriter.java | 4 ++ .../apache/doris/nereids/rules/RuleType.java | 2 + .../analysis/RejectGroupCommitInsert.java | 53 +++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/RejectGroupCommitInsert.java diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java index fcdb357383..e1db7bfb8d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java @@ -28,6 +28,7 @@ import org.apache.doris.nereids.rules.analysis.CheckAfterRewrite; import org.apache.doris.nereids.rules.analysis.EliminateGroupByConstant; import org.apache.doris.nereids.rules.analysis.LogicalSubQueryAliasToLogicalProject; import org.apache.doris.nereids.rules.analysis.NormalizeAggregate; +import org.apache.doris.nereids.rules.analysis.RejectGroupCommitInsert; import org.apache.doris.nereids.rules.expression.CheckLegalityAfterRewrite; import org.apache.doris.nereids.rules.expression.ExpressionNormalization; import org.apache.doris.nereids.rules.expression.ExpressionOptimization; @@ -267,6 +268,9 @@ public class Rewriter extends AbstractBatchJobExecutor { topDown(new BuildAggForUnion()) ), + // TODO remove it after Nereids support group commit insert + topDown(new RejectGroupCommitInsert()), + // topic("Distinct", // costBased(custom(RuleType.PUSH_DOWN_DISTINCT_THROUGH_JOIN, PushdownDistinctThroughJoin::new)) // ), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java index 8319645319..eeec3d30fb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java @@ -76,6 +76,8 @@ public enum RuleType { ANALYZE_CTE(RuleTypeClass.REWRITE), RELATION_AUTHENTICATION(RuleTypeClass.VALIDATION), + REJECT_GROUP_COMMIT_INSERT(RuleTypeClass.REWRITE), + ADJUST_NULLABLE_FOR_PROJECT_SLOT(RuleTypeClass.REWRITE), ADJUST_NULLABLE_FOR_AGGREGATE_SLOT(RuleTypeClass.REWRITE), ADJUST_NULLABLE_FOR_HAVING_SLOT(RuleTypeClass.REWRITE), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/RejectGroupCommitInsert.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/RejectGroupCommitInsert.java new file mode 100644 index 0000000000..19c9706e03 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/RejectGroupCommitInsert.java @@ -0,0 +1,53 @@ +// 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.nereids.exceptions.AnalysisException; +import org.apache.doris.nereids.rules.Rule; +import org.apache.doris.nereids.rules.RuleType; +import org.apache.doris.nereids.rules.rewrite.RewriteRuleFactory; + +import com.google.common.collect.ImmutableList; + +import java.util.List; + +/** + * reject group commit insert added by PR #22829 + */ +public class RejectGroupCommitInsert implements RewriteRuleFactory { + + @Override + public List buildRules() { + return ImmutableList.of( + logicalOlapTableSink(logicalOneRowRelation()) + .thenApply(ctx -> { + if (ctx.connectContext.getSessionVariable().enableInsertGroupCommit) { + throw new AnalysisException("Nereids do not support group commit now."); + } + return null; + }).toRule(RuleType.REJECT_GROUP_COMMIT_INSERT), + logicalOlapTableSink(logicalUnion().when(u -> u.arity() == 0)) + .thenApply(ctx -> { + if (ctx.connectContext.getSessionVariable().enableInsertGroupCommit) { + throw new AnalysisException("Nereids do not support group commit now."); + } + return null; + }).toRule(RuleType.REJECT_GROUP_COMMIT_INSERT) + ); + } +}