This is an automated email from the ASF dual-hosted git repository.
morrysnow 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 b50bc0d2c90 [fix](Nereids) explain should fallback too if Nereids is
not enable (#28475)
b50bc0d2c90 is described below
commit b50bc0d2c902856f6727c5301d256ca6a561f8a3
Author: morrySnow <[email protected]>
AuthorDate: Mon Dec 18 16:44:10 2023 +0800
[fix](Nereids) explain should fallback too if Nereids is not enable (#28475)
---
.../plans/commands/BatchInsertIntoTableCommand.java | 8 ++++++++
.../trees/plans/commands/DeleteFromUsingCommand.java | 10 +++++++++-
.../trees/plans/commands/InsertIntoTableCommand.java | 8 ++++++++
.../plans/commands/InsertOverwriteTableCommand.java | 8 ++++++++
.../nereids/trees/plans/commands/UpdateCommand.java | 18 ++++++++++++++----
.../doris/nereids/trees/plans/UpdateCommandTest.java | 9 ++++-----
6 files changed, 51 insertions(+), 10 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/BatchInsertIntoTableCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/BatchInsertIntoTableCommand.java
index 0e2b6540300..87ab7f73426 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/BatchInsertIntoTableCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/BatchInsertIntoTableCommand.java
@@ -69,6 +69,14 @@ public class BatchInsertIntoTableCommand extends Command
implements ForwardWithS
@Override
public Plan getExplainPlan(ConnectContext ctx) throws Exception {
+ if (!ctx.getSessionVariable().isEnableNereidsDML()) {
+ try {
+ ctx.getSessionVariable().enableFallbackToOriginalPlannerOnce();
+ } catch (Exception e) {
+ throw new AnalysisException("failed to set fallback to
original planner to true", e);
+ }
+ throw new AnalysisException("Nereids DML is disabled, will try to
fall back to the original planner");
+ }
return InsertExecutor.normalizePlan(this.logicalQuery,
InsertExecutor.getTargetTable(this.logicalQuery, ctx));
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromUsingCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromUsingCommand.java
index 8fadeb3b14d..3022578ed60 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromUsingCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromUsingCommand.java
@@ -19,9 +19,9 @@ package org.apache.doris.nereids.trees.plans.commands;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.OlapTable;
-import org.apache.doris.common.AnalysisException;
import org.apache.doris.nereids.analyzer.UnboundSlot;
import org.apache.doris.nereids.analyzer.UnboundTableSink;
+import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Alias;
import org.apache.doris.nereids.trees.expressions.NamedExpression;
import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral;
@@ -123,6 +123,14 @@ public class DeleteFromUsingCommand extends Command
implements ForwardWithSync,
@Override
public Plan getExplainPlan(ConnectContext ctx) {
+ if (!ctx.getSessionVariable().isEnableNereidsDML()) {
+ try {
+ ctx.getSessionVariable().enableFallbackToOriginalPlannerOnce();
+ } catch (Exception e) {
+ throw new AnalysisException("failed to set fallback to
original planner to true", e);
+ }
+ throw new AnalysisException("Nereids DML is disabled, will try to
fall back to the original planner");
+ }
return completeQueryPlan(ctx, logicalQuery);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java
index eaee75936d3..a8dd89f5a93 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java
@@ -232,6 +232,14 @@ public class InsertIntoTableCommand extends Command
implements ForwardWithSync,
@Override
public Plan getExplainPlan(ConnectContext ctx) {
+ if (!ctx.getSessionVariable().isEnableNereidsDML()) {
+ try {
+ ctx.getSessionVariable().enableFallbackToOriginalPlannerOnce();
+ } catch (Exception e) {
+ throw new AnalysisException("failed to set fallback to
original planner to true", e);
+ }
+ throw new AnalysisException("Nereids DML is disabled, will try to
fall back to the original planner");
+ }
return InsertExecutor.normalizePlan(this.logicalQuery,
InsertExecutor.getTargetTable(this.logicalQuery, ctx));
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertOverwriteTableCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertOverwriteTableCommand.java
index 84d3ffc39ca..f353b802678 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertOverwriteTableCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertOverwriteTableCommand.java
@@ -278,6 +278,14 @@ public class InsertOverwriteTableCommand extends Command
implements ForwardWithS
@Override
public Plan getExplainPlan(ConnectContext ctx) {
+ if (!ctx.getSessionVariable().isEnableNereidsDML()) {
+ try {
+ ctx.getSessionVariable().enableFallbackToOriginalPlannerOnce();
+ } catch (Exception e) {
+ throw new AnalysisException("failed to set fallback to
original planner to true", e);
+ }
+ throw new AnalysisException("Nereids DML is disabled, will try to
fall back to the original planner");
+ }
return InsertExecutor.normalizePlan(this.logicalQuery,
InsertExecutor.getTargetTable(this.logicalQuery, ctx));
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java
index 28a78021e02..0410143d0cf 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java
@@ -22,9 +22,9 @@ import org.apache.doris.catalog.KeysType;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf;
-import org.apache.doris.common.AnalysisException;
import org.apache.doris.nereids.analyzer.UnboundSlot;
import org.apache.doris.nereids.analyzer.UnboundTableSink;
+import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.trees.expressions.Alias;
import org.apache.doris.nereids.trees.expressions.EqualTo;
@@ -43,6 +43,7 @@ import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.SessionVariable;
import org.apache.doris.qe.StmtExecutor;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -96,7 +97,8 @@ public class UpdateCommand extends Command implements
ForwardWithSync, Explainab
/**
* add LogicalOlapTableSink node, public for test.
*/
- public LogicalPlan completeQueryPlan(ConnectContext ctx, LogicalPlan
logicalQuery) throws AnalysisException {
+ @VisibleForTesting
+ public LogicalPlan completeQueryPlan(ConnectContext ctx, LogicalPlan
logicalQuery) {
checkTable(ctx);
Map<String, Expression> colNameToExpression = Maps.newHashMap();
@@ -141,7 +143,7 @@ public class UpdateCommand extends Command implements
ForwardWithSync, Explainab
false, ImmutableList.of(), isPartialUpdate,
DMLCommandType.UPDATE, logicalQuery);
}
- private void checkTable(ConnectContext ctx) throws AnalysisException {
+ private void checkTable(ConnectContext ctx) {
if (ctx.getSessionVariable().isInDebugMode()) {
throw new AnalysisException("Update is forbidden since current
session is in debug mode."
+ " Please check the following session variables: "
@@ -160,7 +162,15 @@ public class UpdateCommand extends Command implements
ForwardWithSync, Explainab
}
@Override
- public Plan getExplainPlan(ConnectContext ctx) throws AnalysisException {
+ public Plan getExplainPlan(ConnectContext ctx) {
+ if (!ctx.getSessionVariable().isEnableNereidsDML()) {
+ try {
+ ctx.getSessionVariable().enableFallbackToOriginalPlannerOnce();
+ } catch (Exception e) {
+ throw new AnalysisException("failed to set fallback to
original planner to true", e);
+ }
+ throw new AnalysisException("Nereids DML is disabled, will try to
fall back to the original planner");
+ }
return completeQueryPlan(ctx, logicalQuery);
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/UpdateCommandTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/UpdateCommandTest.java
index cc1789fd8e1..731375c953a 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/UpdateCommandTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/UpdateCommandTest.java
@@ -17,7 +17,6 @@
package org.apache.doris.nereids.trees.plans;
-import org.apache.doris.common.AnalysisException;
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.trees.plans.commands.UpdateCommand;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
@@ -69,10 +68,10 @@ public class UpdateCommandTest extends TestWithFeService
implements PlanPatternM
}
@Test
- public void testSimpleUpdate() throws AnalysisException {
+ public void testSimpleUpdate() {
String sql = "update t1 set v1 = v1 + 2, v2 = v1 * 2 where k1 = 3";
LogicalPlan parsed = new NereidsParser().parseSingle(sql);
- Assertions.assertTrue(parsed instanceof UpdateCommand);
+ Assertions.assertInstanceOf(UpdateCommand.class, parsed);
UpdateCommand command = ((UpdateCommand) parsed);
LogicalPlan plan = command.completeQueryPlan(connectContext,
command.getLogicalQuery());
PlanChecker.from(connectContext, plan)
@@ -90,11 +89,11 @@ public class UpdateCommandTest extends TestWithFeService
implements PlanPatternM
}
@Test
- public void testFromClauseUpdate() throws AnalysisException {
+ public void testFromClauseUpdate() {
String sql = "update t1 a set v1 = t2.v1 + 2, v2 = a.v1 * 2 "
+ "from src join t2 on src.k1 = t2.k1 where t2.k1 = a.k1";
LogicalPlan parsed = new NereidsParser().parseSingle(sql);
- Assertions.assertTrue(parsed instanceof UpdateCommand);
+ Assertions.assertInstanceOf(UpdateCommand.class, parsed);
UpdateCommand command = ((UpdateCommand) parsed);
LogicalPlan plan = command.completeQueryPlan(connectContext,
command.getLogicalQuery());
PlanChecker.from(connectContext, plan)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]