public abstract class RelMetadataQuery extends Object
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, prepending it to the default
providers. Then supply that instance to the planner via the appropriate
plugin mechanism.
| Constructor and Description |
|---|
RelMetadataQuery() |
public static Double getRowCount(RelNode rel)
BuiltInMetadata.RowCount.getRowCount()
statistic.rel - the relational expressionpublic static RelOptCost getCumulativeCost(RelNode rel)
BuiltInMetadata.CumulativeCost.getCumulativeCost()
statistic.rel - the relational expressionpublic static RelOptCost getNonCumulativeCost(RelNode rel)
BuiltInMetadata.NonCumulativeCost.getNonCumulativeCost()
statistic.rel - the relational expressionpublic static Double getPercentageOriginalRows(RelNode rel)
BuiltInMetadata.PercentageOriginalRows.getPercentageOriginalRows()
statistic.rel - the relational expressionpublic static Set<RelColumnOrigin> getColumnOrigins(RelNode rel, int column)
BuiltInMetadata.ColumnOrigin.getColumnOrigins(int)
statistic.rel - the relational expressioncolumn - 0-based ordinal for output column of interestpublic static 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 static RelOptTable getTableOrigin(RelNode rel)
RelNode, provided it maps to a single
table, optionally with filtering and projection.rel - the RelNodepublic static Double getSelectivity(RelNode rel, RexNode predicate)
BuiltInMetadata.Selectivity.getSelectivity(RexNode)
statistic.rel - the relational expressionpredicate - predicate whose selectivity is to be estimated against
rel's outputpublic static Set<ImmutableBitSet> getUniqueKeys(RelNode rel)
BuiltInMetadata.UniqueKeys.getUniqueKeys(boolean)
statistic.rel - the relational expressionpublic static 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 static Boolean areColumnsUnique(RelNode rel, ImmutableBitSet columns)
BuiltInMetadata.ColumnUniqueness.areColumnsUnique(org.apache.calcite.util.ImmutableBitSet, boolean)
statistic.rel - the relational expressioncolumns - column mask representing the subset of columns for which
uniqueness will be determinedpublic static Boolean areColumnsUnique(RelNode rel, ImmutableBitSet columns, boolean ignoreNulls)
BuiltInMetadata.ColumnUniqueness.areColumnsUnique(org.apache.calcite.util.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 static com.google.common.collect.ImmutableList<RelCollation> collations(RelNode rel)
BuiltInMetadata.Collation.collations()
statistic.rel - the relational expressionpublic static RelDistribution distribution(RelNode rel)
BuiltInMetadata.Distribution.distribution()
statistic.rel - the relational expressionpublic static Double getPopulationSize(RelNode rel, ImmutableBitSet groupKey)
BuiltInMetadata.PopulationSize.getPopulationSize(org.apache.calcite.util.ImmutableBitSet)
statistic.rel - the relational expressiongroupKey - column mask representing the subset of columns for which
the row count will be determinedpublic static Double getAverageRowSize(RelNode rel)
BuiltInMetadata.Size.averageRowSize()
statistic.rel - the relational expressionpublic static List<Double> getAverageColumnSizes(RelNode rel)
BuiltInMetadata.Size.averageColumnSizes()
statistic.rel - the relational expressionpublic static List<Double> getAverageColumnSizesNotNull(RelNode rel)
getAverageColumnSizes(org.apache.calcite.rel.RelNode) but
never returns a null list, only ever a list of nulls.public static Boolean isPhaseTransition(RelNode rel)
BuiltInMetadata.Parallelism.isPhaseTransition()
statistic.rel - the relational expressionpublic static Integer splitCount(RelNode rel)
BuiltInMetadata.Parallelism.splitCount()
statistic.rel - the relational expressionpublic static Double memory(RelNode rel)
BuiltInMetadata.Memory.memory()
statistic.rel - the relational expressionpublic static Double cumulativeMemoryWithinPhase(RelNode rel)
BuiltInMetadata.Memory.cumulativeMemoryWithinPhase()
statistic.rel - the relational expressionpublic static Double cumulativeMemoryWithinPhaseSplit(RelNode rel)
BuiltInMetadata.Memory.cumulativeMemoryWithinPhaseSplit()
statistic.rel - the relational expressionpublic static Double getDistinctRowCount(RelNode rel, ImmutableBitSet groupKey, RexNode predicate)
BuiltInMetadata.DistinctRowCount.getDistinctRowCount(org.apache.calcite.util.ImmutableBitSet, org.apache.calcite.rex.RexNode)
statistic.rel - the relational expressiongroupKey - column mask representing group by columnspredicate - pre-filtered predicatespublic static RelOptPredicateList getPulledUpPredicates(RelNode rel)
BuiltInMetadata.Predicates.getPredicates()
statistic.rel - the relational expressionpublic static boolean isVisibleInExplain(RelNode rel, SqlExplainLevel explainLevel)
BuiltInMetadata.ExplainVisibility.isVisibleInExplain(SqlExplainLevel)
statistic.rel - the relational expressionexplainLevel - level of detailCopyright © 2012–2015 The Apache Software Foundation. All rights reserved.