Class RelMdPredicates

java.lang.Object
org.apache.calcite.rel.metadata.RelMdPredicates
All Implemented Interfaces:
MetadataHandler<BuiltInMetadata.Predicates>

public class RelMdPredicates extends Object implements MetadataHandler<BuiltInMetadata.Predicates>
Utility to infer Predicates that are applicable above a RelNode.

This is currently used by JoinPushTransitivePredicatesRule to infer Predicates that can be inferred from one side of a Join to the other.

The PullUp Strategy is sound but not complete. Here are some of the limitations:

  1. For Aggregations we only PullUp predicates that only contain Grouping Keys. This can be extended to infer predicates on Aggregation expressions from expressions on the aggregated columns. For e.g.
     select a, max(b) from R1 where b > 7
       → max(b) > 7 or max(b) is null
     
  2. For Projections we only look at columns that are projected without any function applied. So:
     select a from R1 where a > 7
       → "a > 7" is pulled up from the Projection.
     select a + 1 from R1 where a + 1 > 7
       → "a + 1 gt; 7" is not pulled up
     
  3. There are several restrictions on Joins:
    • 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.
    • For Left Outer: we infer new predicates from the left and set them as applicable on the Right side. No predicates are pulledUp.
    • Right Outer Joins are handled in an analogous manner.
    • For Full Outer Joins no predicates are pulledUp or inferred.