Skip to content

panic when case statement returns null #2798

@kmitchener

Description

@kmitchener

Describe the bug
A clear and concise description of what the bug is.

I've boiled this down to a small test case which panics with this error:
thread 'main' panicked at 'NullArray data should not contain a null buffer, as no buffers are required'

To Reproduce
Steps to reproduce the behavior:

run this SQL from cli:
select case when b is null then null else b end from (select a,b from (values (1,null),(2,3)) as t (a,b)) a;

Expected behavior
A clear and concise description of what you expected to happen.

In Postgres, it returns "null" and 3, as expected.

Additional context
Add any other context about the problem here.

Also, this query returns wrong results, as compared to PG:
select case when b is null then null else b end from (select a,b from (values (1,1),(2,3)) as t (a,b)) a;

in PG, that returns 2 rows: 1 and 3. In Datafusion, it returns 2 nulls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions