Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.26.0
-
None
-
None
Description
It is expected that RexSimplify.simplifyUnknownAs would make the expression "simpler" (e.g. less RexNodes or something like that), however, there's no explicit contract on the resulting expression.
For instance the following expression has non-nullable type
case_(isUnknown(vBool(1)), trueLiteral, vBool(1), falseLiteral, trueLiteral)
however, it might be simplified to the following *nullable* expression:
or(isUnknown(vBool(1)), not(vBool(1)))
Note: the expression never returns null, however, it might be not that obvious that the simplified expression never returns null.
I suggest we add explicit note to simplifyUnknownAs method that says the method is allowed to narrow or widen the nullness of the given expression type
simplifyPreservingType(RexNode, RexUnknownAs, boolean matchNullability) could be used to keep nullness intact.
PS. It woud be nice to simplify or(isUnknown(vBool(1)), not(vBool(1))) to isNotTrue(vBool(1)), however, that is another story. I guess there might be different cases (e.g. involving more complicated cases) that would result in nullability "widening".
Attachments
Issue Links
- is related to
-
CALCITE-4399 Check if HepPlanner should allow to register non-nullable column as an equivalent to nullable
- Open