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

Julian Hyde commented on CALCITE-2247:
--------------------------------------

I agree. I am not a huge fan of unknownAsFalse either. I recall that it was 
introduced to make some simplifications easier to write, because -- the author 
said -- the condition would only be used in a WHERE clause. But, as we have 
seen in this case, if you just step inside a NOT, you are in a situation where 
you want unknown to be treated as true.

Also, it's not clear whether, when you simplify an expression in 
unknownAsFalse-mode, the simplified version must return only false, or whether 
it may return either unknown or false. Are you allowed to simplify "(x > 5) IS 
TRUE" (which returns FALSE if x is NULL) to "x > 5" (which returns UNKNOWN if x 
is NULL)? It isn't clear.

My preferred approach is to wrap every predicate in "... IS TRUE", and simplify 
that. If a boolean expression is used in a context that distinguishes UNKNOWN 
from FALSE (say in a SELECT or GROUP BY clause) then we would leave it as is.

Then we can eliminate unkownAsFalse, as technical debt.

> Add rule to push in condition condition into a related disjunctive expression
> -----------------------------------------------------------------------------
>
>                 Key: CALCITE-2247
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2247
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>
> Simplify expressions like: {code}a = 1 AND (a = 1 OR a = 2){code} to {code}a 
> = 1{code}
> Conditions to apply will be:
> * in an AND condition there exists a comparison(c) and an OR (o)
> * o and c only reference 1 variable
> See HIVE-19097 for more info.



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

Reply via email to