Skip to content

select_columns fails silently when invalid column names are passed #18622

@timsaucer

Description

@timsaucer

Describe the bug

This appears to be a regression from #18236

To Reproduce

I changed the unit test in datafusion/core/tests/dataframe/mod.rs as follows

#[tokio::test]
async fn select_columns() -> Result<()> {
    // build plan using Table API

    let t = test_table().await?;
    let t2 = t.clone().select_columns(&["c1", "c2", "c11"])?;
    let plan = t2.logical_plan().clone();

    // build query using SQL
    let sql_plan = create_plan("SELECT c1, c2, c11 FROM aggregate_test_100").await?;

    // the two plans should be identical
    assert_same_plan(&plan, &sql_plan);

    assert!(t.select_columns(&["non_existent_column"]).is_err());

    Ok(())
}

Expected behavior

I would expect this to return an error as it did before when columns are selected that do not exist. Instead they are simply not present in the output dataframe.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions