public class RelMdPredicates extends java.lang.Object implements MetadataHandler<BuiltInMetadata.Predicates>
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:
select a, max(b) from R1 where b > 7 → max(b) > 7 or max(b) is null
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
Modifier and Type | Class and Description |
---|---|
(package private) static class |
RelMdPredicates.JoinConditionBasedPredicateInference
Utility to infer predicates from one side of the join that apply on the
other side.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.List<RexNode> |
EMPTY_LIST |
static RelMetadataProvider |
SOURCE |
Constructor and Description |
---|
RelMdPredicates() |
public static final RelMetadataProvider SOURCE
private static final java.util.List<RexNode> EMPTY_LIST
public MetadataDef<BuiltInMetadata.Predicates> getDef()
getDef
in interface MetadataHandler<BuiltInMetadata.Predicates>
public RelOptPredicateList getPredicates(RelNode rel, RelMetadataQuery mq)
BuiltInMetadata.Predicates.getPredicates()
,
invoked using reflection.public RelOptPredicateList getPredicates(HepRelVertex rel, RelMetadataQuery mq)
public RelOptPredicateList getPredicates(TableScan table, RelMetadataQuery mq)
public RelOptPredicateList getPredicates(Project project, RelMetadataQuery mq)
inputPullUpExprs: {a > 7, b + c < 10, a + e = 9} projectionExprs: {a, b, c, e / 2} projectionPullupExprs: {a > 7, b + c < 10}
private RexNode projectPredicate(RexBuilder rexBuilder, RelNode input, RexNode r, ImmutableBitSet columnsMapped)
If not possible to simplify, returns true
, which is the weakest
possible predicate.
Examples:
$7 = $9
on columns [7]
becomes $7 is not null
$7 = $9 + $11
on columns [7, 9]
becomes $7 is not null or $9 is not null
$7 = $9 and $9 = 5
on columns [7] becomes
$7 = 5
$7 = $9 and ($9 = $1 or $9 = $2) and $1 > 3 and $2 > 10
on columns [7] becomes $7 > 3
We currently only handle examples 1 and 2.
rexBuilder
- Rex builderinput
- Input relational expressionr
- Predicate expressioncolumnsMapped
- Columns which the final predicate can referencepublic RelOptPredicateList getPredicates(Filter filter, RelMetadataQuery mq)
public RelOptPredicateList getPredicates(Join join, RelMetadataQuery mq)
Join
(including
SemiJoin
).public RelOptPredicateList getPredicates(Aggregate agg, RelMetadataQuery mq)
Pulls up predicates that only contains references to columns in the GroupSet. For e.g.
inputPullUpExprs : { a > 7, b + c < 10, a + e = 9} groupSet : { a, b} pulledUpExprs : { a > 7}
public RelOptPredicateList getPredicates(Union union, RelMetadataQuery mq)
public RelOptPredicateList getPredicates(Sort sort, RelMetadataQuery mq)
public RelOptPredicateList getPredicates(Exchange exchange, RelMetadataQuery mq)
public RelOptPredicateList getPredicates(RelSubset r, RelMetadataQuery mq)
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.