Describe the bug
Case statement, where the first branch is NULL and another one is a number causes "Mismatch between schema and batches" error.
In batch schema, such column has Int32 datatype (or some similar).
In plan schema, such columns have an invalid datatype Null.
To Reproduce
Add this to the middle of pg_compat_union.slt:
statement ok
CREATE TABLE aggregate_test_100_nullable_by_sql AS
SELECT
*,
CASE
WHEN c4 % 3 = 0 THEN NULL
ELSE c5
END AS n5,
CASE
WHEN c3 % 3 != 0 THEN c9
ELSE NULL
END AS n9
FROM aggregate_test_100_by_sql
Under Postgres this statement succeeds.
Expected behavior
To have the same behavior as Postgres: success.
Additional context
No response