Class FlinkRelMdCollation

java.lang.Object
org.apache.flink.table.planner.plan.metadata.FlinkRelMdCollation
All Implemented Interfaces:
org.apache.calcite.rel.metadata.MetadataHandler<org.apache.calcite.rel.metadata.BuiltInMetadata.Collation>

public class FlinkRelMdCollation extends Object implements org.apache.calcite.rel.metadata.MetadataHandler<org.apache.calcite.rel.metadata.BuiltInMetadata.Collation>
FlinkRelMdCollation supplies a default implementation of RelMetadataQuery.collations(org.apache.calcite.rel.RelNode) for the standard logical algebra.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.calcite.rel.metadata.RelMetadataProvider
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<org.apache.calcite.rel.RelCollation>
    calc(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, org.apache.calcite.rex.RexProgram program)
    Helper method to determine a Calc's collation.
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.adapter.enumerable.EnumerableCorrelate join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.adapter.enumerable.EnumerableHashJoin join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.adapter.enumerable.EnumerableMergeJoin join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.adapter.enumerable.EnumerableNestedLoopJoin join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.plan.hep.HepRelVertex rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.plan.volcano.RelSubset subset, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.Calc calc, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.Filter rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.Match rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.Project project, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.SortExchange sort, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.Sort sort, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.TableModify rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.TableScan scan, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.Values values, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.core.Window rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation>
    collations(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    Catch-all implementation for BuiltInMetadata.Collation.collations(), invoked using reflection, for any relational expression not handled by a more specific method.
    static List<org.apache.calcite.rel.RelCollation>
    enumerableBatchNestedLoopJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)
     
    static List<org.apache.calcite.rel.RelCollation>
    enumerableCorrelate(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)
     
    static List<org.apache.calcite.rel.RelCollation>
    enumerableHashJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)
    Returns the collation of EnumerableHashJoin based on its inputs and the join type.
    static List<org.apache.calcite.rel.RelCollation>
    enumerableNestedLoopJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)
    Returns the collation of EnumerableNestedLoopJoin based on its inputs and the join type.
    static List<org.apache.calcite.rel.RelCollation>
    enumerableSemiJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right)
     
    static List<org.apache.calcite.rel.RelCollation>
    filter(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input)
    Helper method to determine a Filter's collation.
    org.apache.calcite.rel.metadata.MetadataDef<org.apache.calcite.rel.metadata.BuiltInMetadata.Collation>
     
    static List<org.apache.calcite.rel.RelCollation>
    limit(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input)
    Helper method to determine a limit's collation.
    static List<org.apache.calcite.rel.RelCollation>
    match(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.rex.RexNode pattern, boolean strictStart, boolean strictEnd, Map<String,org.apache.calcite.rex.RexNode> patternDefinitions, Map<String,org.apache.calcite.rex.RexNode> measures, org.apache.calcite.rex.RexNode after, Map<String,? extends SortedSet<String>> subsets, boolean allRows, org.apache.calcite.util.ImmutableBitSet partitionKeys, org.apache.calcite.rel.RelCollation orderKeys, org.apache.calcite.rex.RexNode interval)
    Helper method to determine a Match's collation.
    static List<org.apache.calcite.rel.RelCollation>
    mergeJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.util.ImmutableIntList leftKeys, org.apache.calcite.util.ImmutableIntList rightKeys)
    Helper method to determine a Join's collation assuming that it uses a merge-join algorithm.
    static List<org.apache.calcite.rel.RelCollation>
    project(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, List<? extends org.apache.calcite.rex.RexNode> projects)
    Helper method to determine a Project's collation.
    static List<org.apache.calcite.rel.RelCollation>
    snapshot(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input)
    Helper method to determine a Snapshot's collation.
    static List<org.apache.calcite.rel.RelCollation>
    sort(org.apache.calcite.rel.RelCollation collation)
    Helper method to determine a Sort's collation.
    static List<org.apache.calcite.rel.RelCollation>
    table(org.apache.calcite.plan.RelOptTable table)
    Helper method to determine a TableScan's collation.
    static List<org.apache.calcite.rel.RelCollation>
    values(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.type.RelDataType rowType, com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexLiteral>> tuples)
    Helper method to determine a Values's collation.
    static List<org.apache.calcite.rel.RelCollation>
    window(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, com.google.common.collect.ImmutableList<org.apache.calcite.rel.core.Window.Group> groups)
    Helper method to determine a Window's collation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SOURCE

      public static final org.apache.calcite.rel.metadata.RelMetadataProvider SOURCE
  • Method Details

    • getDef

      public org.apache.calcite.rel.metadata.MetadataDef<org.apache.calcite.rel.metadata.BuiltInMetadata.Collation> getDef()
      Specified by:
      getDef in interface org.apache.calcite.rel.metadata.MetadataHandler<org.apache.calcite.rel.metadata.BuiltInMetadata.Collation>
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.TableScan scan, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.Values values, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.Project project, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.Filter rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.Calc calc, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.SortExchange sort, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.Sort sort, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.Window rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.adapter.enumerable.EnumerableCorrelate join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.adapter.enumerable.EnumerableMergeJoin join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.adapter.enumerable.EnumerableHashJoin join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.adapter.enumerable.EnumerableNestedLoopJoin join, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.Match rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.core.TableModify rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.plan.hep.HepRelVertex rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.plan.volcano.RelSubset subset, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    • collations

      public com.google.common.collect.ImmutableList<org.apache.calcite.rel.RelCollation> collations(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
      Catch-all implementation for BuiltInMetadata.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:
      • RelMetadataQuery.collations(RelNode)
    • table

      public static List<org.apache.calcite.rel.RelCollation> table(org.apache.calcite.plan.RelOptTable table)
      Helper method to determine a TableScan's collation.
    • values

      public static List<org.apache.calcite.rel.RelCollation> values(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.type.RelDataType rowType, com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexLiteral>> tuples)
      Helper method to determine a Values'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).

    • project

      public static List<org.apache.calcite.rel.RelCollation> project(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, List<? extends org.apache.calcite.rex.RexNode> projects)
      Helper method to determine a Project's collation.
    • filter

      public static List<org.apache.calcite.rel.RelCollation> filter(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input)
      Helper method to determine a Filter's collation.
    • calc

      public static List<org.apache.calcite.rel.RelCollation> calc(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, org.apache.calcite.rex.RexProgram program)
      Helper method to determine a Calc's collation.
    • snapshot

      public static List<org.apache.calcite.rel.RelCollation> snapshot(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input)
      Helper method to determine a Snapshot's collation.
    • sort

      public static List<org.apache.calcite.rel.RelCollation> sort(org.apache.calcite.rel.RelCollation collation)
      Helper method to determine a Sort's collation.
    • limit

      public static List<org.apache.calcite.rel.RelCollation> limit(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input)
      Helper method to determine a limit's collation.
    • window

      public static List<org.apache.calcite.rel.RelCollation> window(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, com.google.common.collect.ImmutableList<org.apache.calcite.rel.core.Window.Group> groups)
      Helper method to determine a Window'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 List<org.apache.calcite.rel.RelCollation> match(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode input, org.apache.calcite.rel.type.RelDataType rowType, org.apache.calcite.rex.RexNode pattern, boolean strictStart, boolean strictEnd, Map<String,org.apache.calcite.rex.RexNode> patternDefinitions, Map<String,org.apache.calcite.rex.RexNode> measures, org.apache.calcite.rex.RexNode after, Map<String,? extends SortedSet<String>> subsets, boolean allRows, org.apache.calcite.util.ImmutableBitSet partitionKeys, org.apache.calcite.rel.RelCollation orderKeys, org.apache.calcite.rex.RexNode interval)
      Helper method to determine a Match's collation.
    • mergeJoin

      public static List<org.apache.calcite.rel.RelCollation> mergeJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.util.ImmutableIntList leftKeys, org.apache.calcite.util.ImmutableIntList rightKeys)
      Helper method to determine a Join'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 List<org.apache.calcite.rel.RelCollation> enumerableHashJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)
      Returns the collation of EnumerableHashJoin based on its inputs and the join type.
    • enumerableNestedLoopJoin

      public static List<org.apache.calcite.rel.RelCollation> enumerableNestedLoopJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)
      Returns the collation of EnumerableNestedLoopJoin based on its inputs and the join type.
    • enumerableCorrelate

      public static List<org.apache.calcite.rel.RelCollation> enumerableCorrelate(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)
    • enumerableSemiJoin

      public static List<org.apache.calcite.rel.RelCollation> enumerableSemiJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right)
    • enumerableBatchNestedLoopJoin

      public static List<org.apache.calcite.rel.RelCollation> enumerableBatchNestedLoopJoin(org.apache.calcite.rel.metadata.RelMetadataQuery mq, org.apache.calcite.rel.RelNode left, org.apache.calcite.rel.RelNode right, org.apache.calcite.rel.core.JoinRelType joinType)