Skip to content

SQL: vam coalesce incorrectly returns null when value has nullable union type #6802

@philrz

Description

@philrz

coalesce is supposed to return the first of its arguments that is not null or an error, so the null value in the following query result indicates a bug.

$ super -s -o mini.sup -c "
values
  {a:1.::(float64|null),b:2.::(float64|null)},
  {a:null::(float64|null),b:2.::(float64|null)}
" &&
super -vam -c "SELECT coalesce(a,b) FROM mini.sup;"

{coalesce:1.::(float64|null)}
{coalesce:null::(float64|null)}

Details

Repro is with super commit cbb4109, which is associated with the merge of the changes from #6633. The query above is a simplification of the sqllogictest query select2/q387.

The correct result is returned if the query is instead run in sequential runtime.

$ super -version
Version: v0.1.0-23-gcbb41094c

$ super -sam -c "SELECT coalesce(a,b) FROM mini.sup;"
{coalesce:1.::(float64|null)}
{coalesce:2.::(float64|null)}

The problem seems unique to values with nullable union types, as I can get the correct result in vector runtime if I drop the unions.

$ super -s -o mini-nounion.sup -c "
values
  {a:1.,b:2.},
  {a:null,b:2.}
" && super -vam -c "SELECT coalesce(a,b) FROM 'mini-nounion.sup';"

{coalesce:1.}
{coalesce:2.}

I can also get the correct result in vector runtime if I go back to the commit right before the changes merged from #6633.

$ super -version
Version: v0.1.0-22-g1bced4402

$ super -vam -c "SELECT coalesce(a,b) FROM mini.sup;"
{coalesce:1.::(float64|null)}
{coalesce:2.::(float64|null)}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions