Skip to content

Add support for EXCLUDE in SELECT #6439

@mustafasrepo

Description

@mustafasrepo

Is your feature request related to a problem or challenge?

Some database systems (such as snowflake) support EXCLUDE syntax, during projection.
For instance, the query below

SELECT * EXCLUDE(ts)
  FROM sales_us

show all the columns except sn, this saves user to write explicitly each desired column.

Describe the solution you'd like

I would like to have this support.

Describe alternatives you've considered

No response

Additional context

To replicate problem, one can use the test below

#[tokio::test]
async fn test_exclude_syntax() -> Result<()> {
    let config = SessionConfig::new()
        .with_target_partitions(1);
    let ctx = SessionContext::with_config(config);
    ctx.sql("CREATE TABLE sales_us (
      ts TIMESTAMP,
      currency VARCHAR(3),
      amount INT
    ) as VALUES
          ('2022-01-01 10:00:00'::timestamp, 'USD', 100.00),
          ('2022-01-01 11:00:00'::timestamp, 'USD', 200.00),
          ('2022-01-02 09:00:00'::timestamp, 'USD', 300.00),
          ('2022-01-02 10:00:00'::timestamp, 'USD', 150.00)").await?;

    let sql = "SELECT * EXCLUDE(ts)
                    FROM sales_us";

    let msg = format!("Creating logical plan for '{sql}'");
    let dataframe = ctx.sql(sql).await.expect(&msg);
    let physical_plan = dataframe.create_physical_plan().await?;
    let batches = collect(physical_plan, ctx.task_ctx()).await?;
    print_batches(&batches)?;
    Ok(())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions