C - Configuration typepublic abstract class MaterializedViewAggregateRule<C extends MaterializedViewAggregateRule.Config> extends MaterializedViewRule<C>
| Modifier and Type | Class and Description |
|---|---|
static interface |
MaterializedViewAggregateRule.Config
Rule configuration.
|
MaterializedViewRule.Edge, MaterializedViewRule.EquivalenceClasses, MaterializedViewRule.MatchModality, MaterializedViewRule.NodeLineage, MaterializedViewRule.ViewPartialRewritingRelRule.Done, RelRule.MatchHandler<R extends RelOptRule>, RelRule.OperandBuilder, RelRule.OperandDetailBuilder<R extends RelNode>, RelRule.OperandTransformRelOptRule.ConverterRelOptRuleOperand| Modifier and Type | Field and Description |
|---|---|
protected static com.google.common.collect.ImmutableList<org.apache.calcite.avatica.util.TimeUnitRange> |
SUPPORTED_DATE_TIME_ROLLUP_UNITS |
description, operands, relBuilderFactory| Modifier and Type | Method and Description |
|---|---|
protected @Nullable MaterializedViewRule.ViewPartialRewriting |
compensateViewPartial(RelBuilder relBuilder,
RexBuilder rexBuilder,
RelMetadataQuery mq,
RelNode input,
@Nullable Project topProject,
RelNode node,
Set<RexTableInputRef.RelTableRef> queryTableRefs,
MaterializedViewRule.EquivalenceClasses queryEC,
@Nullable Project topViewProject,
RelNode viewNode,
Set<RexTableInputRef.RelTableRef> viewTableRefs)
It checks whether the query can be rewritten using the view even though the
query uses additional tables.
|
protected @Nullable RelNode |
createUnion(RelBuilder relBuilder,
RexBuilder rexBuilder,
@Nullable RelNode topProject,
RelNode unionInputQuery,
RelNode unionInputView)
If the view will be used in a union rewriting, this method is responsible for
generating the union and any other operator needed on top of it, e.g., a Project
operator.
|
protected @Nullable com.google.common.collect.Multimap<Integer,Integer> |
generateMapping(RexBuilder rexBuilder,
RexSimplify simplify,
RelMetadataQuery mq,
RelNode node,
RelNode target,
ImmutableBitSet positions,
com.google.common.collect.BiMap<RexTableInputRef.RelTableRef,RexTableInputRef.RelTableRef> tableMapping,
MaterializedViewRule.EquivalenceClasses sourceEC,
List<RexNode> additionalExprs)
Mapping from node expressions to target expressions.
|
protected SqlFunction |
getCeilSqlFunction(org.apache.calcite.avatica.util.TimeUnitRange flag)
Get ceil function datetime.
|
protected SqlFunction |
getFloorSqlFunction(org.apache.calcite.avatica.util.TimeUnitRange flag)
Get floor function datetime.
|
protected @Nullable SqlAggFunction |
getRollup(SqlAggFunction aggregation)
Deprecated.
|
protected boolean |
isValidPlan(@Nullable Project topProject,
RelNode node,
RelMetadataQuery mq) |
Pair<RelNode,RelNode> |
pushFilterToOriginalViewPlan(RelBuilder builder,
@Nullable RelNode topViewProject,
RelNode viewNode,
RexNode cond)
Once we create a compensation predicate, this method is responsible for pushing
the resulting filter through the view nodes.
|
protected @Nullable RelNode |
rewriteQuery(RelBuilder relBuilder,
RexBuilder rexBuilder,
RexSimplify simplify,
RelMetadataQuery mq,
RexNode compensationColumnsEquiPred,
RexNode otherCompensationPred,
@Nullable Project topProject,
RelNode node,
com.google.common.collect.BiMap<RexTableInputRef.RelTableRef,RexTableInputRef.RelTableRef> queryToViewTableMapping,
MaterializedViewRule.EquivalenceClasses viewEC,
MaterializedViewRule.EquivalenceClasses queryEC)
If the view will be used in a union rewriting, this method is responsible for
rewriting the query branch of the union using the given compensation predicate.
|
protected @Nullable RelNode |
rewriteView(RelBuilder relBuilder,
RexBuilder rexBuilder,
RexSimplify simplify,
RelMetadataQuery mq,
MaterializedViewRule.MatchModality matchModality,
boolean unionRewriting,
RelNode input,
@Nullable Project topProject,
RelNode node,
@Nullable Project topViewProject0,
RelNode viewNode,
com.google.common.collect.BiMap<RexTableInputRef.RelTableRef,RexTableInputRef.RelTableRef> queryToViewTableMapping,
MaterializedViewRule.EquivalenceClasses queryEC)
Rewrites the query using the given view query.
|
compensatePartial, computeCompensationPredicates, extractPossibleMapping, extractReferences, generateEquivalenceClasses, generateSwapColumnTableReferencesLineage, generateSwapTableColumnReferencesLineage, generateTableMappings, isValidRelNodePlan, matches, perform, replaceWithOriginalReferences, rewriteExpression, rewriteExpressions, shuttleReferences, shuttleReferences, shuttleReferences, splitPredicatesany, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, none, onMatch, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unorderedprotected static final com.google.common.collect.ImmutableList<org.apache.calcite.avatica.util.TimeUnitRange> SUPPORTED_DATE_TIME_ROLLUP_UNITS
protected boolean isValidPlan(@Nullable Project topProject, RelNode node, RelMetadataQuery mq)
isValidPlan in class MaterializedViewRule<C extends MaterializedViewAggregateRule.Config>protected @Nullable MaterializedViewRule.ViewPartialRewriting compensateViewPartial(RelBuilder relBuilder, RexBuilder rexBuilder, RelMetadataQuery mq, RelNode input, @Nullable Project topProject, RelNode node, Set<RexTableInputRef.RelTableRef> queryTableRefs, MaterializedViewRule.EquivalenceClasses queryEC, @Nullable Project topViewProject, RelNode viewNode, Set<RexTableInputRef.RelTableRef> viewTableRefs)
MaterializedViewRuleRules implementing the method should follow different approaches depending on the operators they rewrite.
compensateViewPartial in class MaterializedViewRule<C extends MaterializedViewAggregateRule.Config>protected @Nullable RelNode rewriteQuery(RelBuilder relBuilder, RexBuilder rexBuilder, RexSimplify simplify, RelMetadataQuery mq, RexNode compensationColumnsEquiPred, RexNode otherCompensationPred, @Nullable Project topProject, RelNode node, com.google.common.collect.BiMap<RexTableInputRef.RelTableRef,RexTableInputRef.RelTableRef> queryToViewTableMapping, MaterializedViewRule.EquivalenceClasses viewEC, MaterializedViewRule.EquivalenceClasses queryEC)
MaterializedViewRuleIf a rewriting can be produced, we return that rewriting. If it cannot be produced, we will return null.
rewriteQuery in class MaterializedViewRule<C extends MaterializedViewAggregateRule.Config>protected @Nullable RelNode createUnion(RelBuilder relBuilder, RexBuilder rexBuilder, @Nullable RelNode topProject, RelNode unionInputQuery, RelNode unionInputView)
MaterializedViewRulecreateUnion in class MaterializedViewRule<C extends MaterializedViewAggregateRule.Config>protected @Nullable RelNode rewriteView(RelBuilder relBuilder, RexBuilder rexBuilder, RexSimplify simplify, RelMetadataQuery mq, MaterializedViewRule.MatchModality matchModality, boolean unionRewriting, RelNode input, @Nullable Project topProject, RelNode node, @Nullable Project topViewProject0, RelNode viewNode, com.google.common.collect.BiMap<RexTableInputRef.RelTableRef,RexTableInputRef.RelTableRef> queryToViewTableMapping, MaterializedViewRule.EquivalenceClasses queryEC)
MaterializedViewRuleThe input node is a Scan on the view table and possibly a compensation Filter on top. If a rewriting can be produced, we return that rewriting. If it cannot be produced, we will return null.
rewriteView in class MaterializedViewRule<C extends MaterializedViewAggregateRule.Config>protected @Nullable com.google.common.collect.Multimap<Integer,Integer> generateMapping(RexBuilder rexBuilder, RexSimplify simplify, RelMetadataQuery mq, RelNode node, RelNode target, ImmutableBitSet positions, com.google.common.collect.BiMap<RexTableInputRef.RelTableRef,RexTableInputRef.RelTableRef> tableMapping, MaterializedViewRule.EquivalenceClasses sourceEC, List<RexNode> additionalExprs)
If any of the expressions cannot be mapped, we return null.
protected SqlFunction getCeilSqlFunction(org.apache.calcite.avatica.util.TimeUnitRange flag)
protected SqlFunction getFloorSqlFunction(org.apache.calcite.avatica.util.TimeUnitRange flag)
@Deprecated protected @Nullable SqlAggFunction getRollup(SqlAggFunction aggregation)
public Pair<RelNode,RelNode> pushFilterToOriginalViewPlan(RelBuilder builder, @Nullable RelNode topViewProject, RelNode viewNode, RexNode cond)
MaterializedViewRuleThe method will return a pair of nodes: the new top project on the left and the new node on the right.
pushFilterToOriginalViewPlan in class MaterializedViewRule<C extends MaterializedViewAggregateRule.Config>Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.