Open
Description
Description
- Truth value handling in the PlanTyper is still buggy.
For example:
Consider:
CASE WHEN NULL THEN 1 ELSE 0 END
This returns:
ERROR : null is/are incompatible data types for the 'CASE_WHEN' operator.
According to SQL spec, the case expression should returns the value of the of the first (leftmost)
whose is true.
Per my understand, NULL should be permitted in the case expression, as NULL IS TRUE
simply returns false.
See also: PostgreSQL link.
This will be a problem for us, practically because we rewrite control flow function like NULLIF
to case when.
i.e.,
NULLIF(a, b)
-- is equivalent to
CASE WHEN a=b THEN NULL ELSE a END -- a=b can return null.
To Reproduce
CASE WHEN NULL THEN 1 ELSE 0 END
java.lang.AssertionError: ERROR:null is/are incompatible data types for the 'CASE_WHEN' operator.
Expected Behavior
Define a better handling mechanism for truth value in the typer.
Additional Context
- Java version: XXX
- PartiQL version: 0.13.2
- Add any other context about the problem here.