xueyumusic commented on issue #7281: bump calcite version to 1.18.0 in druid-sql URL: https://github.com/apache/incubator-druid/pull/7281#issuecomment-482790886 > @xueyumusic, thanks for looking into this. Please check out the comment on the test "testNullStringEquality" - what do you think? Hi, @gianm , thanks a lot for review. The plan `[CASE(=($0, 'a'), =(null, null), =($0, null))]`'s part `=($0, null)` is simplified as `unknownAs` value which is `false` [at here](https://github.com/apache/calcite/blob/branch-1.18/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L250). Since the UNKNOWN policy of equal is [ANY](https://github.com/apache/calcite/blob/branch-1.18/core/src/main/java/org/apache/calcite/plan/Strong.java#L209) so if at least one of its arguments is null [then expr value is null(unknown)](https://github.com/apache/calcite/blob/branch-1.18/core/src/main/java/org/apache/calcite/plan/Strong.java#L113). For `=(null, null)`, `DruidRexExecutor` reduces it as True One way might be that modify `DruidRexExecutor` to keep the same policy as calcite as following (adding strong.isNull check) ``` if (sqlTypeName == SqlTypeName.BOOLEAN) { if (strong.isNull(constExp) && constExp.getKind() == SqlKind.EQUALS) { literal = rexBuilder.makeLiteral(false); //unknownAs is false } else { literal = rexBuilder.makeLiteral(exprResult.asBoolean(), constExp.getType(), true); } } ``` But this way will reduce `=(null, null)` and `=(null, '')`(useDefaultValueForNull) as false, so the test `testEmptyStringEquality`'s result will be affected too and `=(null, null)` as false is a little counter-intuitive What do you think, thanks!
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
