[
https://issues.apache.org/jira/browse/CALCITE-2838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16765384#comment-16765384
]
Zoltan Haindrich commented on CALCITE-2838:
-------------------------------------------
I think about "unknownAsTrue" as an implicit(invisible) "IS TRUE" wrapper -
which makes the "x IS TRUE" expression in uAF mode "doubly checked" in my eye.
* we can probably push "IS TRUE" down in AND/OR independently from this as that
might be generally usefull in other cases as well
* but at the end after pushing down them we would probably end up with some
columns and comparisions locked in IS X boxes ; so I think after all that it
would be probably still needed
* right now I can't think of any example in which "push down (and then
optionally remove)" or "dropping on first sight" would get to different
conclusion
I have the following cases in mind, for which this could help:
{code}
# a comparision is protected by an is true
(x>0 is true) and (x<0)
# the following probably could also benefit from pushdown
(complexExpression is true) and (expr2)
{code}
the problem with "IS TRUE" in the above cases is that it may obstruct other
simplification logics from happening.
note#1: in case of pushing down IS TRUE: consider "(x and y) IS TRUE", if we
rewrite it to "(x IS TRUE) and (y IS TRUE)" - but in case these "IS TRUE"
conditions are not removed, they will make the expression tree "heavier" (more
nodes).
note#2: I can think of the following case in which case pushed down IS TRUEs
might be very usefull: if all usages of X appears as X IS TRUE ; then we can
deduce that X IS TRUE and push that as a filter
> Simplification: Remove redundant IS TRUE checks
> -----------------------------------------------
>
> Key: CALCITE-2838
> URL: https://issues.apache.org/jira/browse/CALCITE-2838
> Project: Calcite
> Issue Type: Improvement
> Reporter: Zoltan Haindrich
> Assignee: Zoltan Haindrich
> Priority: Major
>
> In case simplifcation is already processing in unknownAsFalse mode, {{expr IS
> TRUE}} is redundant - and may just prevent further optimizations from
> happening:
> {code}
> @Test public void testRedundantIsTrue() {
> // in case of unknownAsFalse
> // x is TRUE <=> x
> checkSimplify3(isTrue(vBool(1)),
> "IS TRUE(?0.bool1)",
> "?0.bool1",
> "IS TRUE(?0.bool1)");
> }
> {code}
> there are some further possibilities
> {code}
> (unknownAsTrue) x is NOT FALSE <=> x
> (unknownAsTrue) x is FALSE <=> not x
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)