You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/01/23 14:17:59 UTC

[doris] 01/05: [fix](planner)wrong result when has order by under join (#15974)

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

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 5d5c2e95415feb34f7af30d0482af1c3ad8cb73a
Author: morrySnow <10...@users.noreply.github.com>
AuthorDate: Tue Jan 17 20:20:56 2023 +0800

    [fix](planner)wrong result when has order by under join (#15974)
---
 .../org/apache/doris/planner/ExchangeNode.java     |  5 +--
 .../query_p0/limit/OffsetInSubqueryWithJoin.groovy | 42 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java
index 0629af2295..d613fd9102 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java
@@ -84,9 +84,10 @@ public class ExchangeNode extends PlanNode {
         if (inputNode.getFragment().isPartitioned()) {
             limit = inputNode.limit;
         }
-        offset = inputNode.offset;
+        if (!(inputNode instanceof ExchangeNode)) {
+            offset = inputNode.offset;
+        }
         computeTupleIds();
-
     }
 
     public boolean isMergingExchange() {
diff --git a/regression-test/suites/query_p0/limit/OffsetInSubqueryWithJoin.groovy b/regression-test/suites/query_p0/limit/OffsetInSubqueryWithJoin.groovy
new file mode 100644
index 0000000000..da0c7231f4
--- /dev/null
+++ b/regression-test/suites/query_p0/limit/OffsetInSubqueryWithJoin.groovy
@@ -0,0 +1,42 @@
+// 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.
+
+suite("test_offset_in_subquery_with_join", "query") {
+    // define a sql table
+    def testTable = "test_offset_in_subquery_with_join"
+
+    sql """
+        drop table if exists ${testTable}
+    """
+
+    sql """
+        create table if not exists ${testTable}(id int) distributed by hash(id) properties('replication_num'='1')
+    """
+
+    sql """
+        insert into ${testTable} values (1), (1);
+    """
+
+    test {
+        sql "select * from $testTable where id in (select id from $testTable order by id limit 1, 1)"
+        result([
+                [1],
+                [1]
+        ])
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org