Skip to content

limit_push_down is not working properly with OFFSET #2624

@ming535

Description

@ming535

Describe the bug
limit_push_down tries to push a limit to TableScan when OFFSET is without LIMIT, which makes all the result disappeared.
OFFSET without LIMIT is allowed in Postgres.

To Reproduce
in limit_push_down.rs, add this test code:
`#[test]
fn limit_pushdown_should_not_pushdown_limit_with_offset_only() -> Result<()> {

    let table_scan = test_table_scan()?;
    let plan = LogicalPlanBuilder::from(table_scan)
        .offset(10)?
        .build()?;

    // Should not push any limit down to table provider
    // When it has a select
    let expected = "Offset: 10\
    \n  TableScan: test projection=None";

    assert_optimized_plan_eq(&plan, expected);

    Ok(())
}

`

The problem is here in the code, which adds a limit when OFFSET doesnt have one:
Screen Shot 2022-05-27 at 00 05 17

Expected behavior
The test case should pass. When OFFSET is without LIMIT, then no limit should pushed down to TableScan.

Additional context
I was trying to implement the OFFSET physical plan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingoptimizerOptimizer rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions