Hi, Can anybody clarify if RelRule should be allowed to change RelNode field nullability?
For instance, RelOptRulesTest#testReduceNullableToNotNull has the following SQL: ...empno + *case* when 'a' = 'a' then 1 else *null end* as newcol... Of course, the initial type is nullable int (since the last CASE branch is null), however, you might see that the branch is never taken. A year or so ago the test ensured that the simplified output was +($0, CAST(1):INTEGER, however CALCITE-2852 RexNode simplification does not traverse unknown functions (see [1]) <https://github.com/apache/calcite/pull/1053/files#diff-bc6d90f2392477eb02e40d8bc26ad2d8b0d6bd6dd2714ea0c2b94b3043ff9a8eR6952> altered the behavior, so the actual test output became NEWCOL=[+($0, 1)] which means the rule was allowed to modify row type. It is strange if a rule could replace a RelNode with a different type, so I would expect all transformations to be type-preserving. Should those transformations be allowed? Should the planner deny such transformations? Should the planner add "cast to nullable" in case the original field was nullable? [1]: https://github.com/apache/calcite/pull/1053/files#diff-bc6d90f2392477eb02e40d8bc26ad2d8b0d6bd6dd2714ea0c2b94b3043ff9a8eR6952 Vladimir
