From 22c689568818a7adc0ae5d79cbb7665543bd8ada Mon Sep 17 00:00:00 2001 From: morrySnow Date: Tue, 7 Jan 2025 17:38:23 +0800 Subject: [PATCH] branch-3.0: [fix](Nereids) insert into with cte cannot be explained (#46384) (#46504) pick from master #46384 --- .../trees/plans/commands/insert/InsertIntoTableCommand.java | 6 +++++- .../suites/nereids_p0/explain/explain_dml.groovy | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java index 9048f6c3a0305c..7b1121e5d14b99 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java @@ -314,7 +314,11 @@ public boolean isExternalTableSink() { @Override public Plan getExplainPlan(ConnectContext ctx) { - return InsertUtils.getPlanForExplain(ctx, this.logicalQuery); + Plan plan = InsertUtils.getPlanForExplain(ctx, this.logicalQuery); + if (cte.isPresent()) { + plan = cte.get().withChildren(plan); + } + return plan; } @Override diff --git a/regression-test/suites/nereids_p0/explain/explain_dml.groovy b/regression-test/suites/nereids_p0/explain/explain_dml.groovy index a0ff8c3ba7d2f3..8d041e4dd8472c 100644 --- a/regression-test/suites/nereids_p0/explain/explain_dml.groovy +++ b/regression-test/suites/nereids_p0/explain/explain_dml.groovy @@ -119,4 +119,6 @@ suite("explain_dml") { sql "update duptbl set v1=1 where k1=1;" exception "Only unique table could be updated." } + + sql """explain with tmp as (select 1, 2, '3', 4.0, '2000-01-01') insert into epldel1 select * from tmp""" }