Skip to content

Unparser broken with IS DISTINCT FROM statements #22053

@cetra3

Description

@cetra3

Describe the bug

The Unparser doesn't support IS DISTINCT FROM in statements. This break things, especially with the new array_has null semantics (#21743) and optimizer passes.

I.e, the following fails outright in the unparser:

SELECT value IS DISTINCT FROM 1 FROM t

The following fails after an optimization pass:

SELECT CASE WHEN value > 0 THEN true ELSE false END FROM t

To Reproduce

Simple to fail:

#[tokio::test]
async fn unparse_is_distinct_from() -> Result<()> {
    let ctx = SessionContext::new();

    let schema = Arc::new(Schema::new(vec![Field::new(
        "value",
        DataType::Int32,
        true,
    )]));
    ctx.register_table("t", Arc::new(MemTable::try_new(schema, vec![vec![]])?))?;

    let df = ctx
        .sql("SELECT value IS DISTINCT FROM 1 FROM t")
        .await?;

    let sql = plan_to_sql(df.logical_plan())?;

    Ok(())
}

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions