Skip to content

Inline table scan drops projection #15810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vadimpiven opened this issue Apr 22, 2025 · 3 comments
Closed

Inline table scan drops projection #15810

vadimpiven opened this issue Apr 22, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@vadimpiven
Copy link
Contributor

vadimpiven commented Apr 22, 2025

Describe the bug

PR #15201 introduced a bug here

if table_scan.filters.is_empty() {
- there is a check for filters, but there is no check for projection. As a result - projection is dropped.

To Reproduce

Run the following test and check the assertion fail. The test is successful for 46.0.1 version.

#[test]
fn inline_scan_projection_test() -> Result<()> {
    let name = UNNAMED_TABLE;
    let column = "a";

    let schema = Schema::new(vec![
        Field::new("a", DataType::Int32, false),
        Field::new("b", DataType::Int32, false),
    ]);
    let projection = vec![schema.index_of(column)?];

    let provider = ViewTable::try_new(
        LogicalPlan::EmptyRelation(EmptyRelation {
            produce_one_row: false,
            schema: DFSchemaRef::new(DFSchema::try_from(schema)?),
        }),
        None,
    )?;
    let source = provider_as_source(Arc::new(provider));

    let plan = LogicalPlanBuilder::scan(name, source, Some(projection))?.build()?;
    assert_eq!(
        format!("{plan}"),
        format!("TableScan: {name} projection=[{column}]")
    );

    Ok(())
}

Expected behavior

Projection must be preserved

Additional context

This bug blocks me from update to 47.0.0 version. It would be great to have 47.0.1 version released with the fix.

@vadimpiven vadimpiven added the bug Something isn't working label Apr 22, 2025
@qstommyshu
Copy link
Contributor

I can take a look

@vadimpiven
Copy link
Contributor Author

@qstommyshu I have pushed the fix #15811

@vadimpiven
Copy link
Contributor Author

Closed by #15825

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants