Skip to content

SQL: CAST of NULL to INTEGER produces an error value #6658

@philrz

Description

@philrz

The following SQL query produces an error value when run with super, but a NULL value in Postgres.

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

$ super -c "SELECT CAST (NULL AS INTEGER);"
{"CAST( AS int32)":error({message:"cannot cast to int32",on:null})}

Details

Repro is with super commit cbb4109. The query above is a simplification of sqllogictest random/groupby/slt_good_13/q1160, which is one of many that started similarly failing when the changes were merged from #6633.

Here's the expected result in Postgres:

$ psql postgres
psql (17.8 (Homebrew))
Type "help" for help.

postgres=# \pset null 'NULL'
Null display is "NULL".

postgres=# SELECT CAST (NULL AS INTEGER);
 int4 
------
 NULL
(1 row)

And here was super producing a null result at the commit right before the merge of #6633.

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

$ super -c "SELECT CAST (NULL AS INTEGER);"
{"CAST( AS int32)":null::int32}

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