[ 
https://issues.apache.org/jira/browse/CALCITE-2556?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16613674#comment-16613674
 ] 

Vladimir Sitnikov commented on CALCITE-2556:
--------------------------------------------

[~julianhyde], would you please clarify your question?

{quote}We need to draw the line otherwise we will end up making RexSimplifier 
into a (worse) constant folder.{quote}
That is infeasible.
We would never be able to document exact rules to identify if specific code 
belongs to one class or another one.

However, we seem somehow come to agreement on a case by case basis.


Could we take https://github.com/apache/calcite/pull/831 as an example?
My comments there:
1) The optimization does not really rely on literals. It uses `Strong.Policy` 
to tell if a specific call can be simplified to null or not
2) The code change to {{RexSimplify}} is minimal, and it is very well in line 
with other code
3) There are much more "constant-folding-like" code in RexSimplify:
{code:java}    // Simplify "<literal1> <op> <literal2>"
    // For example, "1 = 2" becomes FALSE;
    // "1 != 1" becomes FALSE;
    // "1 != NULL" becomes UNKNOWN (or FALSE if unknownAsFalse);
    // "1 != '1'" is unchanged because the types are not the same.
    if (o0.isA(SqlKind.LITERAL)
        && o1.isA(SqlKind.LITERAL)
        && o0.getType().equals(o1.getType())) {
      final C v0 = ((RexLiteral) o0).getValueAs(clazz);
      final C v1 = ((RexLiteral) o1).getValueAs(clazz);
{code}
4) The results produce better execution plans => it is an improvement
5) It can be tested via RexFuzzer => the change would have decent coverage


I truly see no drawbacks in merging https://github.com/apache/calcite/pull/831

> RexSimplify: not(trueLiteral) could be simplified to false
> ----------------------------------------------------------
>
>                 Key: CALCITE-2556
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2556
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>            Priority: Major
>




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

Reply via email to