You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (Jira)" <ji...@apache.org> on 2020/11/08 22:35:00 UTC

[jira] [Created] (CALCITE-4387) Document that RexSimplify.simplifyUnknownAs could narrow or widen nullness of the given expression

Vladimir Sitnikov created CALCITE-4387:
------------------------------------------

             Summary: Document that RexSimplify.simplifyUnknownAs could narrow or widen nullness of the given expression
                 Key: CALCITE-4387
                 URL: https://issues.apache.org/jira/browse/CALCITE-4387
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.26.0
         Environment: 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
{noformat}
case_(isUnknown(vBool(1)), trueLiteral, vBool(1), falseLiteral, trueLiteral)
{noformat}

however, it might be simplified to the following **nullable** expression:
{noformat}
or(isUnknown(vBool(1)), not(vBool(1)))
{noformat}

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".
            Reporter: Vladimir Sitnikov






--
This message was sent by Atlassian Jira
(v8.3.4#803005)