zed icon indicating copy to clipboard operation
zed copied to clipboard

SQL: Mixing NULL values with another uniform type in VALUES

Open philrz opened this issue 7 months ago • 0 comments

This fails in SuperDB but works in Postgres.

$ super -version
Version: 7f23f6560

$ super -c "SELECT * FROM (VALUES (NULL, NULL), (3, 4), (3, 7)) v1;"
values clause must contain uniformly typed values at line 1, column 37:
SELECT * FROM (VALUES (NULL, NULL), (3, 4), (3, 7)) v1;
                                    ~~~~~~
values clause must contain uniformly typed values at line 1, column 45:
SELECT * FROM (VALUES (NULL, NULL), (3, 4), (3, 7)) v1;
                                            ~~~~~~

Details

Repro is with super commit 7f23f65. This was found via a query from a sqllogictest.

This works in Postgres.

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

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

postgres=# SELECT * FROM (VALUES (NULL, NULL), (3, 4), (3, 7)) v1;
 column1 | column2 
---------+---------
    NULL |    NULL
       3 |       4
       3 |       7
(3 rows)

If we try to mix types of non-NULL values, indeed Postgres does reject it as well.

postgres=# SELECT * FROM (VALUES (NULL, NULL), ('a', 4), (3, 7)) v1;
ERROR:  invalid input syntax for type integer: "a"
LINE 1: SELECT * FROM (VALUES (NULL, NULL), ('a', 4), (3, 7)) v1;
                                             ^

But it does seem like we'd want to match the behavior where NULL values can be mixed with values of any other single type.

philrz avatar Jul 09 '25 19:07 philrz