Skip to content

Commit

Permalink
enhancement: when fetch == 0, pushdown limit 0 instead skip+fetch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Nov 23, 2022
1 parent d355f69 commit 5ee8559
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions datafusion/optimizer/src/limit_push_down.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl OptimizerRule for LimitPushDown {

let plan = match &*limit.input {
LogicalPlan::TableScan(scan) => {
let limit = fetch + skip;
let limit = if fetch != 0 { fetch + skip } else { 0 };
let new_input = LogicalPlan::TableScan(TableScan {
table_name: scan.table_name.clone(),
source: scan.source.clone(),
Expand Down Expand Up @@ -756,7 +756,7 @@ mod test {
.build()?;

let expected = "Limit: skip=1000, fetch=0\
\n TableScan: test, fetch=1000";
\n TableScan: test, fetch=0";

assert_optimized_plan_eq(&plan, expected)
}
Expand All @@ -771,7 +771,7 @@ mod test {
.build()?;

let expected = "Limit: skip=1000, fetch=0\
\n TableScan: test, fetch=1000";
\n TableScan: test, fetch=0";

assert_optimized_plan_eq(&plan, expected)
}
Expand Down

0 comments on commit 5ee8559

Please sign in to comment.