public class RelMetadataQuery
extends java.lang.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
, pre-pending it to the default
providers. Then supply that instance to the planner via the appropriate
plugin mechanism.
Modifier | Constructor and Description |
---|---|
private |
RelMetadataQuery(boolean dummy)
Creates and initializes the instance that will serve as a prototype for
all other instances.
|
protected |
RelMetadataQuery(JaninoRelMetadataProvider metadataProvider,
RelMetadataQuery prototype) |
public final java.util.Map<java.util.List,java.lang.Object> map
public final JaninoRelMetadataProvider metadataProvider
protected static final RelMetadataQuery EMPTY
private BuiltInMetadata.Collation.Handler collationHandler
private BuiltInMetadata.ColumnOrigin.Handler columnOriginHandler
private BuiltInMetadata.ExpressionLineage.Handler expressionLineageHandler
private BuiltInMetadata.TableReferences.Handler tableReferencesHandler
private BuiltInMetadata.ColumnUniqueness.Handler columnUniquenessHandler
private BuiltInMetadata.CumulativeCost.Handler cumulativeCostHandler
private BuiltInMetadata.DistinctRowCount.Handler distinctRowCountHandler
private BuiltInMetadata.Distribution.Handler distributionHandler
private BuiltInMetadata.ExplainVisibility.Handler explainVisibilityHandler
private BuiltInMetadata.MaxRowCount.Handler maxRowCountHandler
private BuiltInMetadata.MinRowCount.Handler minRowCountHandler
private BuiltInMetadata.Memory.Handler memoryHandler
private BuiltInMetadata.NonCumulativeCost.Handler nonCumulativeCostHandler
private BuiltInMetadata.Parallelism.Handler parallelismHandler
private BuiltInMetadata.PercentageOriginalRows.Handler percentageOriginalRowsHandler
private BuiltInMetadata.PopulationSize.Handler populationSizeHandler
private BuiltInMetadata.Predicates.Handler predicatesHandler
private BuiltInMetadata.AllPredicates.Handler allPredicatesHandler
private BuiltInMetadata.NodeTypes.Handler nodeTypesHandler
private BuiltInMetadata.RowCount.Handler rowCountHandler
private BuiltInMetadata.Selectivity.Handler selectivityHandler
private BuiltInMetadata.Size.Handler sizeHandler
private BuiltInMetadata.UniqueKeys.Handler uniqueKeysHandler
public static final java.lang.ThreadLocal<JaninoRelMetadataProvider> THREAD_PROVIDERS
protected RelMetadataQuery(JaninoRelMetadataProvider metadataProvider, RelMetadataQuery prototype)
private RelMetadataQuery(boolean dummy)
protected static <H> H initialHandler(java.lang.Class<H> handlerClass)
public static RelMetadataQuery instance()
protected <M extends Metadata,H extends MetadataHandler<M>> H revise(java.lang.Class<? extends RelNode> class_, MetadataDef<M> def)
class_
if it is not already present.public com.google.common.collect.Multimap<java.lang.Class<? extends RelNode>,RelNode> getNodeTypes(RelNode rel)
BuiltInMetadata.NodeTypes.getNodeTypes()
statistic.rel
- the relational expressionpublic java.lang.Double getRowCount(RelNode rel)
BuiltInMetadata.RowCount.getRowCount()
statistic.rel
- the relational expressionpublic java.lang.Double getMaxRowCount(RelNode rel)
BuiltInMetadata.MaxRowCount.getMaxRowCount()
statistic.rel
- the relational expressionpublic java.lang.Double getMinRowCount(RelNode rel)
BuiltInMetadata.MinRowCount.getMinRowCount()
statistic.rel
- the relational expressionpublic RelOptCost getCumulativeCost(RelNode rel)
BuiltInMetadata.CumulativeCost.getCumulativeCost()
statistic.rel
- the relational expressionpublic RelOptCost getNonCumulativeCost(RelNode rel)
BuiltInMetadata.NonCumulativeCost.getNonCumulativeCost()
statistic.rel
- the relational expressionpublic java.lang.Double getPercentageOriginalRows(RelNode rel)
BuiltInMetadata.PercentageOriginalRows.getPercentageOriginalRows()
statistic.rel
- the relational expressionpublic java.util.Set<RelColumnOrigin> getColumnOrigins(RelNode rel, int column)
BuiltInMetadata.ColumnOrigin.getColumnOrigins(int)
statistic.rel
- the relational expressioncolumn
- 0-based ordinal for output column of interestpublic 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 java.util.Set<RexNode> getExpressionLineage(RelNode rel, RexNode expression)
public java.util.Set<RexTableInputRef.RelTableRef> getTableReferences(RelNode rel)
public RelOptTable getTableOrigin(RelNode rel)
RelNode
, provided it maps to a single
table, optionally with filtering and projection.rel
- the RelNodepublic java.lang.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 java.util.Set<ImmutableBitSet> getUniqueKeys(RelNode rel)
BuiltInMetadata.UniqueKeys.getUniqueKeys(boolean)
statistic.rel
- the relational expressionpublic java.util.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 java.lang.Boolean areRowsUnique(RelNode rel)
BuiltInMetadata.ColumnUniqueness.areColumnsUnique(org.apache.calcite.util.ImmutableBitSet, boolean)
statistic over all columns.rel
- the relational expressionpublic java.lang.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 java.lang.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 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 java.lang.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 java.lang.Double getAverageRowSize(RelNode rel)
BuiltInMetadata.Size.averageRowSize()
statistic.rel
- the relational expressionpublic java.util.List<java.lang.Double> getAverageColumnSizes(RelNode rel)
BuiltInMetadata.Size.averageColumnSizes()
statistic.rel
- the relational expressionpublic java.util.List<java.lang.Double> getAverageColumnSizesNotNull(RelNode rel)
getAverageColumnSizes(org.apache.calcite.rel.RelNode)
but
never returns a null list, only ever a list of nulls.public java.lang.Boolean isPhaseTransition(RelNode rel)
BuiltInMetadata.Parallelism.isPhaseTransition()
statistic.rel
- the relational expressionpublic java.lang.Integer splitCount(RelNode rel)
BuiltInMetadata.Parallelism.splitCount()
statistic.rel
- the relational expressionpublic java.lang.Double memory(RelNode rel)
BuiltInMetadata.Memory.memory()
statistic.rel
- the relational expressionpublic java.lang.Double cumulativeMemoryWithinPhase(RelNode rel)
BuiltInMetadata.Memory.cumulativeMemoryWithinPhase()
statistic.rel
- the relational expressionpublic java.lang.Double cumulativeMemoryWithinPhaseSplit(RelNode rel)
BuiltInMetadata.Memory.cumulativeMemoryWithinPhaseSplit()
statistic.rel
- the relational expressionpublic java.lang.Double getDistinctRowCount(RelNode rel, ImmutableBitSet groupKey, 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 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 detailprivate static java.lang.Double validatePercentage(java.lang.Double result)
public RelDistribution getDistribution(RelNode rel)
BuiltInMetadata.Distribution.distribution()
statistic.rel
- the relational expressionprivate static boolean isPercentage(java.lang.Double result, boolean fail)
private static boolean isNonNegative(java.lang.Double result, boolean fail)
private static java.lang.Double validateResult(java.lang.Double result)
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.