This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit d34f1d861a2cbef19065086377eb5cbf7c7454da
Author: morrySnow <[email protected]>
AuthorDate: Mon Oct 9 14:52:36 2023 +0800

    [fix](Nereids) deep copier generate wrong slot for TVF (#25156)
---
 .../org/apache/doris/nereids/trees/copier/LogicalPlanDeepCopier.java | 2 +-
 regression-test/data/nereids_p0/with/test_with.out                   | 5 +++++
 regression-test/suites/nereids_p0/with/test_with.groovy              | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/copier/LogicalPlanDeepCopier.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/copier/LogicalPlanDeepCopier.java
index 12455b66f2e..39f7fb310b4 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/copier/LogicalPlanDeepCopier.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/copier/LogicalPlanDeepCopier.java
@@ -219,7 +219,7 @@ public class LogicalPlanDeepCopier extends 
DefaultPlanRewriter<DeepCopierContext
         }
         LogicalTVFRelation newTVFRelation = new 
LogicalTVFRelation(StatementScopeIdGenerator.newRelationId(),
                 tvfRelation.getFunction());
-        updateReplaceMapWithOutput(newTVFRelation, tvfRelation, 
context.exprIdReplaceMap);
+        updateReplaceMapWithOutput(tvfRelation, newTVFRelation, 
context.exprIdReplaceMap);
         context.putRelation(tvfRelation.getRelationId(), newTVFRelation);
         return newTVFRelation;
     }
diff --git a/regression-test/data/nereids_p0/with/test_with.out 
b/regression-test/data/nereids_p0/with/test_with.out
index cd4b4766029..d4cf0a1151b 100644
--- a/regression-test/data/nereids_p0/with/test_with.out
+++ b/regression-test/data/nereids_p0/with/test_with.out
@@ -30,3 +30,8 @@
 2
 3
 
+-- !tvf_in_cte --
+0
+1
+2
+
diff --git a/regression-test/suites/nereids_p0/with/test_with.groovy 
b/regression-test/suites/nereids_p0/with/test_with.groovy
index 555662b9e22..39db78a2570 100644
--- a/regression-test/suites/nereids_p0/with/test_with.groovy
+++ b/regression-test/suites/nereids_p0/with/test_with.groovy
@@ -48,5 +48,8 @@ suite("test_with") {
                 SELECT * FROM outermost ORDER BY 1;
               """
 
+    order_qt_tvf_in_cte """
+        with a as (select number from numbers("number"="3")) select * from a;
+    """
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to