Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felixwluo committed Aug 13, 2024
1 parent 7502935 commit 868c22e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1827,17 +1827,19 @@ public PlanFragment visitPhysicalNestedLoopJoin(

@Override
public PlanFragment visitPhysicalLimit(PhysicalLimit<? extends Plan> physicalLimit, PlanTranslatorContext context) {
Plan childPlan = physicalLimit.child(0);
PlanFragment inputFragment = physicalLimit.child(0).accept(this, context);
PlanNode child = inputFragment.getPlanRoot();
if (childPlan instanceof PhysicalLimit) {
child.setLimit(Math.min(physicalLimit.getLimit() + physicalLimit.getOffset(), child.getLimit()));

if (!(inputFragment.getPlanRoot() instanceof ExchangeNode)) {
inputFragment.getPlanRoot().setLimit(physicalLimit.getLimit());
inputFragment.getPlanRoot().setOffset(physicalLimit.getOffset());
return inputFragment;
} else {
child.setLimit(MergeLimits.mergeLimit(physicalLimit.getLimit(), physicalLimit.getOffset(),
child.getLimit()));
// TODO: plan node don't support limit
// child.setOffset(MergeLimits.mergeOffset(physicalLimit.getOffset(), child.getOffset()));
}
// TODO: plan node don't support limit
// child.setOffset(MergeLimits.mergeOffset(physicalLimit.getOffset(), child.getOffset()));
updateLegacyPlanIdToPhysicalPlan(child, physicalLimit);
return inputFragment;
}
Expand Down
8 changes: 0 additions & 8 deletions regression-test/suites/nereids_syntax_p0/test_limit.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ suite("test_limit") {
sql 'set enable_nereids_planner=true'
sql 'set enable_fallback_to_original_planner=false'

def DBname = "limit_test_db"
sql "DROP DATABASE IF EXISTS ${DBname}"
sql "CREATE DATABASE IF NOT EXISTS ${DBname}"
sql "use ${DBname}"

sql """
drop table if exists test1
"""
Expand Down Expand Up @@ -80,7 +75,4 @@ suite("test_limit") {
select row_number() over(order by k6 desc) k6s, t.* from row_number_limit_tbl t limit 1 offset 2;
"""

sql """ drop database IF EXISTS ${DBname} """


}

0 comments on commit 868c22e

Please sign in to comment.