Class RelMdPredicates.JoinConditionBasedPredicateInference

  • Enclosing class:

    static class RelMdPredicates.JoinConditionBasedPredicateInference
    extends java.lang.Object
    Utility to infer predicates from one side of the join that apply on the other side.

    Contract is:

    • initialize with a Join and optional predicates applicable on its left and right subtrees.
    • you can then ask it for equivalentPredicate(s) given a predicate.

    So for:

    1. 'R1(x) join R2(y) on x = y' a call for equivalentPredicates on 'x > 7' will return ' [y > 7]'
    2. 'R1(x) join R2(y) on x = y join R3(z) on y = z' a call for equivalentPredicates on the second join 'x > 7' will return
    • Field Detail

      • joinRel

        final Join joinRel
      • nSysFields

        final int nSysFields
      • nFieldsLeft

        final int nFieldsLeft
      • nFieldsRight

        final int nFieldsRight
      • equivalence

        java.util.SortedMap<java.lang.Integer,​java.util.BitSet> equivalence
      • allExprs

        final java.util.Set<RexNode> allExprs
      • equalityPredicates

        final java.util.Set<RexNode> equalityPredicates
      • leftChildPredicates

        final RexNode leftChildPredicates
      • rightChildPredicates

        final RexNode rightChildPredicates
    • Constructor Detail

      • JoinConditionBasedPredicateInference

        JoinConditionBasedPredicateInference​(Join joinRel,
                                             RexNode leftPredicates,
                                             RexNode rightPredicates,
                                             RexSimplify simplify)
    • Method Detail

      • inferPredicates

        public RelOptPredicateList inferPredicates​(boolean includeEqualityInference)
        The PullUp Strategy is sound but not complete.
        1. We only pullUp inferred predicates for now. Pulling up existing predicates causes an explosion of duplicates. The existing predicates are pushed back down as new predicates. Once we have rules to eliminate duplicate Filter conditions, we should pullUp all predicates.
        2. For Left Outer: we infer new predicates from the left and set them as applicable on the Right side. No predicates are pulledUp.
        3. Right Outer Joins are handled in an analogous manner.
        4. For Full Outer Joins no predicates are pulledUp or inferred.
      • infer

        private void infer​(RexNode predicates,
                           java.util.Set<RexNode> allExprs,
                           java.util.List<RexNode> inferredPredicates,
                           boolean includeEqualityInference,
                           ImmutableBitSet inferringFields)
      • mappings

        java.lang.Iterable<Mapping> mappings​(RexNode predicate)
      • markAsEquivalent

        private void markAsEquivalent​(int p1,
                                      int p2)
      • pos

        private int pos​(RexNode expr)
      • isAlwaysTrue

        private boolean isAlwaysTrue​(RexNode predicate)