[ https://issues.apache.org/jira/browse/CALCITE-2247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16434518#comment-16434518 ]
Julian Hyde commented on CALCITE-2247: -------------------------------------- I thought about this some more. RexSimplify has predicates. Suppose after you've seen {{a = 1}} you create a new RexSimplify with {{a = 1}} as a predicate. Then you can simplify {{a = 1 OR a = 2}} to {{a = 1}}. This way, we would be able to deal with more complex cases, e.g. simplify {{a > 10 and (a = 5 or a = 15)}} to {{a = 15}}. There's a slight problem with this: it's very dependent on the order of the items in the AND. We would not be able to optimize {{(a = 5 or a = 15) and a > 10}}, for instance. But we can live with that. Whatever algorithm you choose, you should add tests to {{RexProgramTest}}. We need to be able to test simplifications as unit tests, not just as part of {{RelOptRulesTest}}. > 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)