Skip to content

Drop columns only allows unqualified names and silently fails otherwise #19548

@ntjohnson1

Description

@ntjohnson1

Describe the bug

If we try to drop a column using drop_columns but with a qualified name table.col then it doesn't match and silently skips the attempt to drop the column. See repro below where I'd expect the plans to match.

To Reproduce

let mut t = test_table().await?;
t = t.select_columns(&["c1", "c2", "c11"])?;
let mut t2 = test_table_with_name("another_table").await?;
t2 = t2.select_columns(&["c1", "c2", "c11"])?;
let mut t3 = t.join_on(
   t2,
   JoinType::Inner,
   [col("aggregate_test_100.c1").eq(col("another_table.c1"))],
)?;
t3 = t3.drop_columns(&["another_table.c2", "another_table.c11"])?;

let plan = t3.logical_plan().clone();

let sql = "SELECT aggregate_test_100.c1, aggregate_test_100.c2, aggregate_test_100.c11, another_table.c1  FROM (SELECT c1, c2, c11 FROM aggregate_test_100) INNER JOIN (SELECT c1, c2, c11 FROM another_table) ON aggregate_test_100.c1 = another_table.c1";
let ctx = SessionContext::new();
register_aggregate_csv(&ctx, "aggregate_test_100").await?;
register_aggregate_csv(&ctx, "another_table").await?;
let sql_plan = ctx.sql(sql).await?.into_unoptimized_plan();

Expected behavior

The sql plans match. Or (less nice) the documentation mentions this limitation and there is an error.

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