[ https://issues.apache.org/jira/browse/CALCITE-2247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16483390#comment-16483390 ]
Julian Hyde commented on CALCITE-2247: -------------------------------------- I was thinking along similar lines. We could pass an "interpretation" function. In your example the interpretation function maps true → true, unknown → false, false → true and is commonly called IS NOT UNKNOWN. There are 27 (3^3) functions that map (false, unknown, true) to (false, unknown, true). Here are the most interesting 11: ||false ||unknown ||true ||Name |false |unknown |true |identity |true |unknown |false |NOT |false |false |true |IS TRUE |true |true |false |IS NOT TRUE |true |false |false |IS FALSE |false |true |true |IS NOT FALSE |false |true |false |IS UNKNOWN |true |false |true |IS NOT UNKNOWN |false |false |false |FALSE |unknown |unknown |unknown |UNKNOWN |true |true |true |TRUE For the purposes of simplification, I think that 3 cover the main cases without making the code too complicated: * IS TRUE (unknown-as-false) is used when a predicate occurs in WHERE, ON or HAVING; * IS NOT FALSE (unknown-as-true) occurs in NOT and OR; * Identifier (unknown-as-unknown) occurs when a condition appears in the SELECT clause, and therefore you want 3-valued logic returned. > 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)