[fix](planner)wrong result when has order by under join (#15974)

This commit is contained in:
morrySnow
2023-01-17 20:20:56 +08:00
committed by GitHub
parent e6a5d3375e
commit 02a7995171
2 changed files with 45 additions and 2 deletions

View File

@ -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() {

View File

@ -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]
])
}
}