You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Andrew Pilloud (JIRA)" <ji...@apache.org> on 2019/01/10 23:31:00 UTC

[jira] [Created] (CALCITE-2783) Null checks incorrectly optimized by RexSimplfy.simplifyBooleanCase.

Andrew Pilloud created CALCITE-2783:
---------------------------------------

             Summary: Null checks incorrectly optimized by RexSimplfy.simplifyBooleanCase.
                 Key: CALCITE-2783
                 URL: https://issues.apache.org/jira/browse/CALCITE-2783
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.18.0
         Environment: Using Apache Beam 1ad4affb450809842670df0434e12d953af31e166. (See BEAM-6401).

Does not reproduce on Calcite 064974d543874e47a9da8ea0595824dde398bee1.

Does reproduce on Calcite b470a0cd4572c9f6c4c0e9b51926b97c5af58d3f, 1.18, and master@62b47aeeb7eeb59beaf5b8f3b54a5c58ba4ca76d.

(This is introduced by CALCITE-1413)
            Reporter: Andrew Pilloud
            Assignee: Julian Hyde


This first appears in 1.18, and is introduced by CALCITE-1413.

I have a table "table" with column "f0" of nullable booleans. Table contains the following values:
{code:java}
true
false
null
{code}
Working query:
{code:java}
SELECT coalesce(f0, true) FROM table;

true
false
true
{code}
Broken query:
{code:java}
SELECT coalesce(f0, true) = true FROM table;

Caused by: java.lang.NullPointerException
 at org.apache.calcite.runtime.SqlFunctions.cannotConvert(SqlFunctions.java:1457)
 at org.apache.calcite.runtime.SqlFunctions.toBoolean(SqlFunctions.java:1480)
 at SC.eval0(Unknown Source)
{code}
Broken generated code:
{code:java}
{
 final Boolean inp0_ = ((Row) c.element()).getBoolean(0);
 c.output(Row.withSchema(outputSchema).addValue((SqlFunctions.isTrue(inp0_) || inp0_ == null ? Boolean.TRUE : inp0_ == null ? (Boolean) null : Boolean.FALSE) == null ? (Boolean) null : Boolean.valueOf(SqlFunctions.toBoolean(inp0_) || inp0_ == null)).build());
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)