Class RelMdCollation
- All Implemented Interfaces:
MetadataHandler<BuiltInMetadata.Collation>
RelMetadataQuery.collations(org.apache.calcite.rel.RelNode)
for the standard logical algebra.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable List<RelCollation>
calc
(RelMetadataQuery mq, RelNode input, RexProgram program) Helper method to determine aCalc
's collation.@Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(EnumerableCorrelate join, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(EnumerableHashJoin join, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(EnumerableLimit rel, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(EnumerableMergeJoin join, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(EnumerableMergeUnion mergeUnion, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
@Nullable com.google.common.collect.ImmutableList<RelCollation>
@Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(HepRelVertex rel, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(RelSubset rel, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(Calc calc, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(Filter rel, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(Match rel, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(Project project, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(SortExchange sort, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(Sort sort, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(TableModify rel, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(TableScan scan, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(Values values, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(Window rel, RelMetadataQuery mq) @Nullable com.google.common.collect.ImmutableList<RelCollation>
collations
(RelNode rel, RelMetadataQuery mq) Catch-all implementation forBuiltInMetadata.Collation.collations()
, invoked using reflection, for any relational expression not handled by a more specific method.static com.google.common.collect.Ordering<List<RexLiteral>>
comparator
(RelFieldCollation fieldCollation) static @Nullable List<RelCollation>
enumerableBatchNestedLoopJoin
(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType) static @Nullable List<RelCollation>
enumerableCorrelate
(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType) static @Nullable List<RelCollation>
enumerableHashJoin
(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType) Returns the collation ofEnumerableHashJoin
based on its inputs and the join type.static @Nullable List<RelCollation>
enumerableNestedLoopJoin
(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType) Returns the collation ofEnumerableNestedLoopJoin
based on its inputs and the join type.static @Nullable List<RelCollation>
enumerableSemiJoin
(RelMetadataQuery mq, RelNode left, RelNode right) static @Nullable List<RelCollation>
filter
(RelMetadataQuery mq, RelNode input) Helper method to determine aFilter
's collation.getDef()
static @Nullable List<RelCollation>
limit
(RelMetadataQuery mq, RelNode input) Helper method to determine a limit's collation.static @Nullable List<RelCollation>
match
(RelMetadataQuery mq, RelNode input, RelDataType rowType, RexNode pattern, boolean strictStart, boolean strictEnd, Map<String, RexNode> patternDefinitions, Map<String, RexNode> measures, RexNode after, Map<String, ? extends SortedSet<String>> subsets, boolean allRows, ImmutableBitSet partitionKeys, RelCollation orderKeys, @Nullable RexNode interval) Helper method to determine aMatch
's collation.static @Nullable List<RelCollation>
mergeJoin
(RelMetadataQuery mq, RelNode left, RelNode right, ImmutableIntList leftKeys, ImmutableIntList rightKeys) Deprecated.static @Nullable List<RelCollation>
mergeJoin
(RelMetadataQuery mq, RelNode left, RelNode right, ImmutableIntList leftKeys, ImmutableIntList rightKeys, JoinRelType joinType) Helper method to determine aJoin
's collation assuming that it uses a merge-join algorithm.static @Nullable List<RelCollation>
project
(RelMetadataQuery mq, RelNode input, List<? extends RexNode> projects) Helper method to determine aProject
's collation.static @Nullable List<RelCollation>
snapshot
(RelMetadataQuery mq, RelNode input) Helper method to determine aSnapshot
's collation.static List<RelCollation>
sort
(RelCollation collation) Helper method to determine aSort
's collation.static @Nullable List<RelCollation>
table
(RelOptTable table) Helper method to determine aTableScan
's collation.static List<RelCollation>
values
(RelMetadataQuery mq, RelDataType rowType, com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<RexLiteral>> tuples) Helper method to determine aValues
's collation.static @Nullable List<RelCollation>
window
(RelMetadataQuery mq, RelNode input, com.google.common.collect.ImmutableList<Window.Group> groups) Helper method to determine aWindow
's collation.
-
Field Details
-
SOURCE
-
-
Method Details
-
getDef
- Specified by:
getDef
in interfaceMetadataHandler<BuiltInMetadata.Collation>
-
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(RelNode rel, RelMetadataQuery mq) Catch-all implementation forBuiltInMetadata.Collation.collations()
, invoked using reflection, for any relational expression not handled by a more specific method.Union
,Intersect
,Minus
,Join
,Correlate
do not in general return sorted results (but implementations using particular algorithms may).- Parameters:
rel
- Relational expression- Returns:
- Relational expression's collations
- See Also:
-
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(Window rel, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(Match rel, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(Filter rel, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(TableModify rel, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(TableScan scan, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(EnumerableMergeJoin join, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(EnumerableHashJoin join, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(EnumerableNestedLoopJoin join, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(EnumerableMergeUnion mergeUnion, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(EnumerableCorrelate join, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(EnumerableLimit rel, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(Sort sort, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(SortExchange sort, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(Project project, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(Calc calc, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(Values values, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(JdbcToEnumerableConverter rel, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(HepRelVertex rel, RelMetadataQuery mq) -
collations
public @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(RelSubset rel, RelMetadataQuery mq) -
table
Helper method to determine aTableScan
's collation. -
snapshot
Helper method to determine aSnapshot
's collation. -
sort
Helper method to determine aSort
's collation. -
filter
Helper method to determine aFilter
's collation. -
limit
Helper method to determine a limit's collation. -
calc
public static @Nullable List<RelCollation> calc(RelMetadataQuery mq, RelNode input, RexProgram program) Helper method to determine aCalc
's collation. -
project
public static @Nullable List<RelCollation> project(RelMetadataQuery mq, RelNode input, List<? extends RexNode> projects) Helper method to determine aProject
's collation. -
window
public static @Nullable List<RelCollation> window(RelMetadataQuery mq, RelNode input, com.google.common.collect.ImmutableList<Window.Group> groups) Helper method to determine aWindow
's collation.A Window projects the fields of its input first, followed by the output from each of its windows. Assuming (quite reasonably) that the implementation does not re-order its input rows, then any collations of its input are preserved.
-
match
public static @Nullable List<RelCollation> match(RelMetadataQuery mq, RelNode input, RelDataType rowType, RexNode pattern, boolean strictStart, boolean strictEnd, Map<String, RexNode> patternDefinitions, Map<String, RexNode> measures, RexNode after, Map<String, ? extends SortedSet<String>> subsets, boolean allRows, ImmutableBitSet partitionKeys, RelCollation orderKeys, @Nullable RexNode interval) Helper method to determine aMatch
's collation. -
values
public static List<RelCollation> values(RelMetadataQuery mq, RelDataType rowType, com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<RexLiteral>> tuples) Helper method to determine aValues
's collation.We actually under-report the collations. A Values with 0 or 1 rows - an edge case, but legitimate and very common - is ordered by every permutation of every subset of the columns.
So, our algorithm aims to:
- produce at most N collations (where N is the number of columns);
- make each collation as long as possible;
- do not repeat combinations already emitted -
if we've emitted
(a, b)
do not later emit(b, a)
; - probe the actual values and make sure that each collation is consistent with the data
So, for an empty Values with 4 columns, we would emit
(a, b, c, d), (b, c, d), (c, d), (d)
. -
comparator
public static com.google.common.collect.Ordering<List<RexLiteral>> comparator(RelFieldCollation fieldCollation) -
mergeJoin
@Deprecated public static @Nullable List<RelCollation> mergeJoin(RelMetadataQuery mq, RelNode left, RelNode right, ImmutableIntList leftKeys, ImmutableIntList rightKeys) Deprecated.Helper method to determine aJoin
's collation assuming that it uses a merge-join algorithm.If the inputs are sorted on other keys in addition to the join key, the result preserves those collations too.
-
mergeJoin
public static @Nullable List<RelCollation> mergeJoin(RelMetadataQuery mq, RelNode left, RelNode right, ImmutableIntList leftKeys, ImmutableIntList rightKeys, JoinRelType joinType) Helper method to determine aJoin
's collation assuming that it uses a merge-join algorithm.If the inputs are sorted on other keys in addition to the join key, the result preserves those collations too.
-
enumerableHashJoin
public static @Nullable List<RelCollation> enumerableHashJoin(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType) Returns the collation ofEnumerableHashJoin
based on its inputs and the join type. -
enumerableNestedLoopJoin
public static @Nullable List<RelCollation> enumerableNestedLoopJoin(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType) Returns the collation ofEnumerableNestedLoopJoin
based on its inputs and the join type. -
enumerableCorrelate
public static @Nullable List<RelCollation> enumerableCorrelate(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType) -
enumerableSemiJoin
public static @Nullable List<RelCollation> enumerableSemiJoin(RelMetadataQuery mq, RelNode left, RelNode right) -
enumerableBatchNestedLoopJoin
public static @Nullable List<RelCollation> enumerableBatchNestedLoopJoin(RelMetadataQuery mq, RelNode left, RelNode right, JoinRelType joinType)
-
mergeJoin(RelMetadataQuery, RelNode, RelNode, ImmutableIntList, ImmutableIntList, JoinRelType)