Class FlinkRelMetadataQuery

java.lang.Object
org.apache.calcite.rel.metadata.RelMetadataQueryBase
org.apache.calcite.rel.metadata.RelMetadataQuery
org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery

public class FlinkRelMetadataQuery extends org.apache.calcite.rel.metadata.RelMetadataQuery
A RelMetadataQuery that defines extended metadata handler in Flink, e.g ColumnInterval, ColumnNullCount.
  • Field Summary

    Fields inherited from class org.apache.calcite.rel.metadata.RelMetadataQueryBase

    map, metadataProvider, THREAD_PROVIDERS
  • Method Summary

    Modifier and Type
    Method
    Description
    FlinkRelDistribution
    flinkDistribution(org.apache.calcite.rel.RelNode rel)
    Returns the FlinkRelDistribution statistic.
    ValueInterval
    getColumnInterval(org.apache.calcite.rel.RelNode rel, int index)
    Returns the FlinkMetadata.ColumnInterval statistic.
    getColumnNullCount(org.apache.calcite.rel.RelNode rel, int index)
    Returns the null count of the given column.
    getColumnOriginNullCount(org.apache.calcite.rel.RelNode rel, int index)
    Returns origin null count of the given column.
    ValueInterval
    getFilteredColumnInterval(org.apache.calcite.rel.RelNode rel, int columnIndex, int filterArg)
    Returns the FlinkMetadata.ColumnInterval of the given column under the given filter argument.
    RelModifiedMonotonicity
    getRelModifiedMonotonicity(org.apache.calcite.rel.RelNode rel)
    Returns the RelModifiedMonotonicity statistic.
    getRelWindowProperties(org.apache.calcite.rel.RelNode rel)
    Returns the RelWindowProperties statistic.
    org.apache.calcite.util.ImmutableBitSet
    getUniqueGroups(org.apache.calcite.rel.RelNode rel, org.apache.calcite.util.ImmutableBitSet columns)
    Returns the (minimum) unique groups of the given columns.
    Set<org.apache.calcite.util.ImmutableBitSet>
    getUpsertKeys(org.apache.calcite.rel.RelNode rel)
    Determines the set of upsert minimal keys for this expression.
    Set<org.apache.calcite.util.ImmutableBitSet>
    getUpsertKeysInKeyGroupRange(org.apache.calcite.rel.RelNode rel, int[] partitionKeys)
    Determines the set of upsert minimal keys in a single key group range, which means can ignore exchange by partition keys.
    Returns an instance of FlinkRelMetadataQuery.
    reuseOrCreate(org.apache.calcite.rel.metadata.RelMetadataQuery mq)
    Reuse input metadataQuery instance if it could cast to FlinkRelMetadataQuery class, or create one if not.

    Methods inherited from class org.apache.calcite.rel.metadata.RelMetadataQuery

    areColumnsUnique, areColumnsUnique, areRowsUnique, areRowsUnique, collations, cumulativeMemoryWithinPhase, cumulativeMemoryWithinPhaseSplit, distribution, getAllPredicates, getAverageColumnSizes, getAverageColumnSizesNotNull, getAverageRowSize, getColumnOrigin, getColumnOrigins, getCumulativeCost, getDistinctRowCount, getDistribution, getExpressionLineage, getLowerBoundCost, getMaxRowCount, getMinRowCount, getNodeTypes, getNonCumulativeCost, getPercentageOriginalRows, getPopulationSize, getPulledUpPredicates, getRowCount, getSelectivity, getTableOrigin, getTableReferences, getUniqueKeys, getUniqueKeys, isPhaseTransition, isVisibleInExplain, memory, splitCount

    Methods inherited from class org.apache.calcite.rel.metadata.RelMetadataQueryBase

    clearCache, handler, initialHandler, revise, revise

    Methods inherited from class java.lang.Object

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

    • instance

      public static FlinkRelMetadataQuery instance()
      Returns an instance of FlinkRelMetadataQuery. It ensures that cycles do not occur while computing metadata.
    • reuseOrCreate

      public static FlinkRelMetadataQuery reuseOrCreate(org.apache.calcite.rel.metadata.RelMetadataQuery mq)
      Reuse input metadataQuery instance if it could cast to FlinkRelMetadataQuery class, or create one if not.
      Parameters:
      mq - metadataQuery which try to reuse
      Returns:
      a FlinkRelMetadataQuery instance
    • getColumnInterval

      public ValueInterval getColumnInterval(org.apache.calcite.rel.RelNode rel, int index)
      Returns the FlinkMetadata.ColumnInterval statistic.
      Parameters:
      rel - the relational expression
      index - the index of the given column
      Returns:
      the interval of the given column of a specified relational expression. Returns null if interval cannot be estimated, Returns org.apache.flink.table.planner.plan.stats.EmptyValueInterval if column values does not contains any value except for null.
    • getFilteredColumnInterval

      public ValueInterval getFilteredColumnInterval(org.apache.calcite.rel.RelNode rel, int columnIndex, int filterArg)
      Returns the FlinkMetadata.ColumnInterval of the given column under the given filter argument.
      Parameters:
      rel - the relational expression
      columnIndex - the index of the given column
      filterArg - the index of the filter argument
      Returns:
      the interval of the given column of a specified relational expression. Returns null if interval cannot be estimated, Returns org.apache.flink.table.planner.plan.stats.EmptyValueInterval if column values does not contains any value except for null.
    • getColumnNullCount

      public Double getColumnNullCount(org.apache.calcite.rel.RelNode rel, int index)
      Returns the null count of the given column.
      Parameters:
      rel - the relational expression
      index - the index of the given column
      Returns:
      the null count of the given column if can be estimated, else return null.
    • getColumnOriginNullCount

      public Double getColumnOriginNullCount(org.apache.calcite.rel.RelNode rel, int index)
      Returns origin null count of the given column.
      Parameters:
      rel - the relational expression
      index - the index of the given column
      Returns:
      the null count of the given column if can be estimated, else return null.
    • getUniqueGroups

      public org.apache.calcite.util.ImmutableBitSet getUniqueGroups(org.apache.calcite.rel.RelNode rel, org.apache.calcite.util.ImmutableBitSet columns)
      Returns the (minimum) unique groups of the given columns.
      Parameters:
      rel - the relational expression
      columns - the given columns in a specified relational expression. The given columns should not be null.
      Returns:
      the (minimum) unique columns which should be a sub-collection of the given columns, and should not be null or empty. If none unique columns can be found, return the given columns.
    • flinkDistribution

      public FlinkRelDistribution flinkDistribution(org.apache.calcite.rel.RelNode rel)
      Returns the FlinkRelDistribution statistic.
      Parameters:
      rel - the relational expression
      Returns:
      description of how the rows in the relational expression are physically distributed
    • getRelModifiedMonotonicity

      public RelModifiedMonotonicity getRelModifiedMonotonicity(org.apache.calcite.rel.RelNode rel)
      Returns the RelModifiedMonotonicity statistic.
      Parameters:
      rel - the relational expression
      Returns:
      the monotonicity for the corresponding RelNode
    • getRelWindowProperties

      public RelWindowProperties getRelWindowProperties(org.apache.calcite.rel.RelNode rel)
      Returns the RelWindowProperties statistic.
      Parameters:
      rel - the relational expression
      Returns:
      the window properties for the corresponding RelNode
    • getUpsertKeys

      public Set<org.apache.calcite.util.ImmutableBitSet> getUpsertKeys(org.apache.calcite.rel.RelNode rel)
      Determines the set of upsert minimal keys for this expression. A key is represented as an ImmutableBitSet, where each bit position represents a 0-based output column ordinal.

      Different from the unique keys: In distributed streaming computing, one record may be divided into RowKind.UPDATE_BEFORE and RowKind.UPDATE_AFTER. If a key changing join is connected downstream, the two records will be divided into different tasks, resulting in disorder. In this case, the downstream cannot rely on the order of the original key. So in this case, it has unique keys in the traditional sense, but it doesn't have upsert keys.

      Returns:
      set of keys, or null if this information cannot be determined (whereas empty set indicates definitely no keys at all)
    • getUpsertKeysInKeyGroupRange

      public Set<org.apache.calcite.util.ImmutableBitSet> getUpsertKeysInKeyGroupRange(org.apache.calcite.rel.RelNode rel, int[] partitionKeys)
      Determines the set of upsert minimal keys in a single key group range, which means can ignore exchange by partition keys.

      Some optimizations can rely on this ability to do upsert in a single key group range.