Xianqing He created IMPALA-15632:
------------------------------------

             Summary: Add disjunctive subsumption rewrite rule for OR predicates
                 Key: IMPALA-15632
                 URL: https://issues.apache.org/jira/browse/IMPALA-15632
             Project: IMPALA
          Issue Type: Improvement
          Components: Frontend
    Affects Versions: Impala 5.0.0
            Reporter: Xianqing He


h3. Problem
Impala has limited support for removing redundant disjuncts in OR predicates. 
{{ExtractCommonConjunctRule}} handles only single-layer absorption, and 
{{EqualityDisjunctsToInRule}} only merges equality/IN disjuncts. Predicates 
such as {{a = 1 OR (a = 1 AND b = 2) OR a = 2 OR (a = 2 AND b = 3)}} are only 
partially simplified, leading to redundant CNF expansion and missed IN 
conversion.

h3. Proposed change
Add a new frontend rewrite rule {{SimplifyDisjunctiveSubsumptionRule}} that:
* flattens OR trees and compares the deduplicated conjunct sets of disjuncts
* removes a disjunct when another disjunct's conjunct set is a strict subset of 
it ({{D' OR (D' AND E) = D'}})
* removes duplicate disjuncts using a stable tie-break
* conservatively skips subqueries and non-deterministic builtins 
(rand/random/uuid)
* bounds the comparison work (30x30, same constant as 
{{ExtractCommonConjunctRule}})

Register the rule after {{ExtractCommonConjunctRule}} and before 
{{ConvertToCNFRule}}, gated by a new query option 
{{enable_disjunctive_subsumption_rewrite}} (default true). The rewrite is safe 
in SQL three-valued logic because only conjunct-set supersets are removed.

h3. Testing
* Unit tests in {{ExprRewriteRulesTest}}, including 3VL/NULL cases, duplicate 
disjuncts/conjuncts, chained subsumption, subquery/nondeterministic guards, 
cost-gate boundaries, and full analysis pipeline
* Planner tests updated for affected TPCDS q13 variants



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to