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 TypeMethodDescriptionFlinkRelDistributionflinkDistribution(org.apache.calcite.rel.RelNode rel) Returns theFlinkRelDistributionstatistic.ValueIntervalgetColumnInterval(org.apache.calcite.rel.RelNode rel, int index) Returns theFlinkMetadata.ColumnIntervalstatistic.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.ValueIntervalgetFilteredColumnInterval(org.apache.calcite.rel.RelNode rel, int columnIndex, int filterArg) Returns theFlinkMetadata.ColumnIntervalof the given column under the given filter argument.RelModifiedMonotonicitygetRelModifiedMonotonicity(org.apache.calcite.rel.RelNode rel) Returns theRelModifiedMonotonicitystatistic.getRelWindowProperties(org.apache.calcite.rel.RelNode rel) Returns theRelWindowPropertiesstatistic.org.apache.calcite.util.ImmutableBitSetgetUniqueGroups(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.static FlinkRelMetadataQueryinstance()Returns an instance of FlinkRelMetadataQuery.static FlinkRelMetadataQueryreuseOrCreate(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, splitCountMethods inherited from class org.apache.calcite.rel.metadata.RelMetadataQueryBase
clearCache, handler, initialHandler, revise, revise
-
Method Details
-
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 theFlinkMetadata.ColumnIntervalstatistic.- Parameters:
rel- the relational expressionindex- 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.EmptyValueIntervalif 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 theFlinkMetadata.ColumnIntervalof the given column under the given filter argument.- Parameters:
rel- the relational expressioncolumnIndex- the index of the given columnfilterArg- 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.EmptyValueIntervalif column values does not contains any value except for null.
-
getColumnNullCount
Returns the null count of the given column.- Parameters:
rel- the relational expressionindex- the index of the given column- Returns:
- the null count of the given column if can be estimated, else return null.
-
getColumnOriginNullCount
Returns origin null count of the given column.- Parameters:
rel- the relational expressionindex- 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 expressioncolumns- 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 theFlinkRelDistributionstatistic.- 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 theRelModifiedMonotonicitystatistic.- Parameters:
rel- the relational expression- Returns:
- the monotonicity for the corresponding RelNode
-
getRelWindowProperties
Returns theRelWindowPropertiesstatistic.- 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 anImmutableBitSet, 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.
-