public class RelMetadataQuery extends RelMetadataQueryBase
RelMetadataProvider for the set of relational expression metadata
queries defined as standard within Calcite. The Javadoc on these methods
serves as their primary specification.
To add a new standard query Xyz to this interface, follow
these steps:
getXyz specification to this class.
org.apache.calcite.test.RelMetadataTest.
RelMdXyz in this package. Follow
the pattern from an existing class such as RelMdColumnOrigins,
overloading on all of the logical relational expressions to which the query
applies.
SOURCE static member, similar to
RelMdColumnOrigins.SOURCE.
SOURCE object in DefaultRelMetadataProvider.
Because relational expression metadata is extensible, extension projects
can define similar facades in order to specify access to custom metadata.
Please do not add queries here (nor on RelNode) which lack meaning
outside of your extension.
Besides adding new metadata queries, extension projects may need to add
custom providers for the standard queries in order to handle additional
relational expressions (either logical or physical). In either case, the
process is the same: write a reflective provider and chain it on to an
instance of DefaultRelMetadataProvider, pre-pending it to the default
providers. Then supply that instance to the planner via the appropriate
plugin mechanism.
map, metadataProvider, THREAD_PROVIDERS| Modifier | Constructor and Description |
|---|---|
protected |
RelMetadataQuery()
Creates the instance with
JaninoRelMetadataProvider instance
from RelMetadataQueryBase.THREAD_PROVIDERS and EMPTY as a prototype. |
|
RelMetadataQuery(MetadataHandlerProvider provider)
Create a RelMetadataQuery with a given
MetadataHandlerProvider. |
clearCache, handler, initialHandler, revise, reviseprotected RelMetadataQuery()
JaninoRelMetadataProvider instance
from RelMetadataQueryBase.THREAD_PROVIDERS and EMPTY as a prototype.public RelMetadataQuery(MetadataHandlerProvider provider)
MetadataHandlerProvider.provider - The provider to use for construction.public static RelMetadataQuery instance()
public @Nullable com.google.common.collect.Multimap<Class<? extends RelNode>,RelNode> getNodeTypes(RelNode rel)
BuiltInMetadata.NodeTypes.getNodeTypes()
statistic.rel - the relational expressionpublic Double getRowCount(RelNode rel)
BuiltInMetadata.RowCount.getRowCount()
statistic.rel - the relational expressionpublic @Nullable Double getMaxRowCount(RelNode rel)
BuiltInMetadata.MaxRowCount.getMaxRowCount()
statistic.rel - the relational expressionpublic @Nullable Double getMinRowCount(RelNode rel)
BuiltInMetadata.MinRowCount.getMinRowCount()
statistic.rel - the relational expressionpublic @Nullable RelOptCost getCumulativeCost(RelNode rel)
BuiltInMetadata.CumulativeCost.getCumulativeCost()
statistic.rel - the relational expressionpublic @Nullable RelOptCost getNonCumulativeCost(RelNode rel)
BuiltInMetadata.NonCumulativeCost.getNonCumulativeCost()
statistic.rel - the relational expressionpublic @Nullable Double getPercentageOriginalRows(RelNode rel)
BuiltInMetadata.PercentageOriginalRows.getPercentageOriginalRows()
statistic.rel - the relational expressionpublic @Nullable Set<RelColumnOrigin> getColumnOrigins(RelNode rel, int column)
BuiltInMetadata.ColumnOrigin.getColumnOrigins(int)
statistic.rel - the relational expressioncolumn - 0-based ordinal for output column of interestpublic @Nullable RelColumnOrigin getColumnOrigin(RelNode rel, int column)
rel - the RelNode of the columncolumn - the offset of the column whose origin we are trying to
determinegetColumnOrigins(org.apache.calcite.rel.RelNode, int)public @Nullable Set<RexNode> getExpressionLineage(RelNode rel, RexNode expression)
public @Nullable Set<RexTableInputRef.RelTableRef> getTableReferences(RelNode rel)
public @Nullable RelOptTable getTableOrigin(RelNode rel)
RelNode, provided it maps to a single
table, optionally with filtering and projection.rel - the RelNodepublic @Nullable Double getSelectivity(RelNode rel, @Nullable RexNode predicate)
BuiltInMetadata.Selectivity.getSelectivity(RexNode)
statistic.rel - the relational expressionpredicate - predicate whose selectivity is to be estimated against
rel's outputpublic @Nullable Set<ImmutableBitSet> getUniqueKeys(RelNode rel)
BuiltInMetadata.UniqueKeys.getUniqueKeys(boolean)
statistic.rel - the relational expressionpublic @Nullable Set<ImmutableBitSet> getUniqueKeys(RelNode rel, boolean ignoreNulls)
BuiltInMetadata.UniqueKeys.getUniqueKeys(boolean)
statistic.rel - the relational expressionignoreNulls - if true, ignore null values when determining
whether the keys are uniquepublic @Nullable Boolean areRowsUnique(RelNode rel, boolean ignoreNulls)
This is derived by applying the
BuiltInMetadata.ColumnUniqueness.areColumnsUnique(org.apache.calcite.util.ImmutableBitSet, boolean)
statistic over all columns. If
BuiltInMetadata.MaxRowCount.getMaxRowCount()
is less than or equal to one, we shortcut the process and declare the rows
unique.
rel - the relational expressionignoreNulls - if true, ignore null values when determining column
uniquenesspublic @Nullable Boolean areRowsUnique(RelNode rel)
Derived by calling areRowsUnique(RelNode, boolean).
rel - the relational expressionpublic @Nullable Boolean areColumnsUnique(RelNode rel, ImmutableBitSet columns)
BuiltInMetadata.ColumnUniqueness.areColumnsUnique(ImmutableBitSet, boolean)
statistic.rel - the relational expressioncolumns - column mask representing the subset of columns for which
uniqueness will be determinedpublic @Nullable Boolean areColumnsUnique(RelNode rel, ImmutableBitSet columns, boolean ignoreNulls)
BuiltInMetadata.ColumnUniqueness.areColumnsUnique(ImmutableBitSet, boolean)
statistic.rel - the relational expressioncolumns - column mask representing the subset of columns for which
uniqueness will be determinedignoreNulls - if true, ignore null values when determining column
uniquenesspublic @Nullable com.google.common.collect.ImmutableList<RelCollation> collations(RelNode rel)
BuiltInMetadata.Collation.collations()
statistic.rel - the relational expressionpublic RelDistribution distribution(RelNode rel)
BuiltInMetadata.Distribution.distribution()
statistic.rel - the relational expressionpublic @Nullable Double getPopulationSize(RelNode rel, ImmutableBitSet groupKey)
BuiltInMetadata.PopulationSize.getPopulationSize(ImmutableBitSet)
statistic.rel - the relational expressiongroupKey - column mask representing the subset of columns for which
the row count will be determinedpublic @Nullable Double getAverageRowSize(RelNode rel)
BuiltInMetadata.Size.averageRowSize()
statistic.rel - the relational expressionpublic @Nullable List<Double> getAverageColumnSizes(RelNode rel)
BuiltInMetadata.Size.averageColumnSizes()
statistic.rel - the relational expressionpublic List<Double> getAverageColumnSizesNotNull(RelNode rel)
getAverageColumnSizes(org.apache.calcite.rel.RelNode) but
never returns a null list, only ever a list of nulls.public @Nullable Boolean isPhaseTransition(RelNode rel)
BuiltInMetadata.Parallelism.isPhaseTransition()
statistic.rel - the relational expressionpublic @Nullable Integer splitCount(RelNode rel)
BuiltInMetadata.Parallelism.splitCount()
statistic.rel - the relational expressionpublic @Nullable Double memory(RelNode rel)
BuiltInMetadata.Memory.memory()
statistic.rel - the relational expressionpublic @Nullable Double cumulativeMemoryWithinPhase(RelNode rel)
BuiltInMetadata.Memory.cumulativeMemoryWithinPhase()
statistic.rel - the relational expressionpublic @Nullable Double cumulativeMemoryWithinPhaseSplit(RelNode rel)
BuiltInMetadata.Memory.cumulativeMemoryWithinPhaseSplit()
statistic.rel - the relational expressionpublic @Nullable Double getDistinctRowCount(RelNode rel, ImmutableBitSet groupKey, @Nullable RexNode predicate)
BuiltInMetadata.DistinctRowCount.getDistinctRowCount(ImmutableBitSet, RexNode)
statistic.rel - the relational expressiongroupKey - column mask representing group by columnspredicate - pre-filtered predicatespublic RelOptPredicateList getPulledUpPredicates(RelNode rel)
BuiltInMetadata.Predicates.getPredicates()
statistic.rel - the relational expressionpublic @Nullable RelOptPredicateList getAllPredicates(RelNode rel)
BuiltInMetadata.AllPredicates.getAllPredicates()
statistic.rel - the relational expressionpublic Boolean isVisibleInExplain(RelNode rel, SqlExplainLevel explainLevel)
BuiltInMetadata.ExplainVisibility.isVisibleInExplain(SqlExplainLevel)
statistic.rel - the relational expressionexplainLevel - level of detailpublic @Nullable RelDistribution getDistribution(RelNode rel)
BuiltInMetadata.Distribution.distribution()
statistic.rel - the relational expressionpublic @Nullable RelOptCost getLowerBoundCost(RelNode rel, VolcanoPlanner planner)
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.