[ https://issues.apache.org/jira/browse/CALCITE-2783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16744031#comment-16744031 ]
Zoltan Haindrich commented on CALCITE-2783: ------------------------------------------- I was able to fix this; and because it has a "dual" issue in AND I've started fixing that as well - but it seems like there is another issue here; it seems like {{IsXxxImplementor}} is ignoring {{nullAs}} settings; so for in case {{NullAs.IS_NULL}}; instead of translating to {{FALSE}}; it actually calculates the value IS_X value. https://github.com/apache/calcite/blob/73f71095ef4e66aa47563e28b02f3fd499a5a1ad/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java#L2535 > 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: Zoltan Haindrich > Priority: Major > > 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)