Class DruidCorrelateUnnestRel

java.lang.Object
org.apache.calcite.rel.AbstractRelNode
org.apache.druid.sql.calcite.rel.DruidRel<DruidCorrelateUnnestRel>
org.apache.druid.sql.calcite.rel.DruidCorrelateUnnestRel
All Implemented Interfaces:
Cloneable, org.apache.calcite.plan.RelOptNode, org.apache.calcite.rel.RelNode

public class DruidCorrelateUnnestRel extends DruidRel<DruidCorrelateUnnestRel>
This is the DruidRel to handle correlated rel nodes to be used for unnest. Each correlate can be perceived as a join with the join type being inner the left of a correlate as seen in the rule DruidCorrelateUnnestRule is the DruidQueryRel while the right will always be an DruidUnnestRel.

Since this is a subclass of DruidRel it is automatically considered by other rules that involves DruidRels. Some example being SELECT_PROJECT and SORT_PROJECT rules in DruidRules.DruidQueryRule

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Shuttle that replaces correlating variables with regular field accesses to the left-hand side.

    Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode

    org.apache.calcite.rel.RelNode.Context
  • Field Summary

    Fields inherited from class org.apache.calcite.rel.AbstractRelNode

    digest, id, rowType, traitSet
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a copy of this rel with the DruidConvention trait.
    static boolean
    Computes whether a particular left-side rel requires a subquery, or if we can operate on its underlying datasource directly.
    org.apache.calcite.plan.RelOptCost
    computeSelfCost(org.apache.calcite.plan.RelOptPlanner planner, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
     
    org.apache.calcite.rel.RelNode
    copy(org.apache.calcite.plan.RelTraitSet traitSet, List<org.apache.calcite.rel.RelNode> inputs)
     
    create(org.apache.calcite.rel.core.Correlate correlateRel, PlannerContext plannerContext)
    Create an instance from a Correlate that is based on a DruidRel and a DruidUnnestRel inputs.
    protected org.apache.calcite.rel.type.RelDataType
     
    org.apache.calcite.rel.RelWriter
    explainTerms(org.apache.calcite.rel.RelWriter pw)
    Overridden to ensure that subclasses provide a proper implementation.
    Get the set of names of table datasources read by this DruidRel
    List<org.apache.calcite.rel.RelNode>
     
    Returns the PartialDruidQuery associated with this DruidRel, and which can be built on top of.
    toDruidQuery(boolean finalizeAggregations)
    Convert this DruidRel to a DruidQuery.
    Convert this DruidRel to a DruidQuery for purposes of explaining.
     

    Methods inherited from class org.apache.druid.sql.calcite.rel.DruidRel

    clone, getPlannerContext, isValidDruidQuery, runQuery, unwrapLogicalPlan

    Methods inherited from class org.apache.calcite.rel.AbstractRelNode

    accept, accept, childrenAccept, collectVariablesSet, collectVariablesUsed, deepEquals, deepHashCode, equals, estimateRowCount, explain, getCluster, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getRelDigest, getRelTypeName, getRowType, getTable, getTraitSet, getVariablesSet, hashCode, isEnforcer, isValid, metadata, onRegister, recomputeDigest, register, replaceInput, sole, toString

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.calcite.rel.RelNode

    explain, fieldIsNullable, stripped
  • Method Details

    • create

      public static DruidCorrelateUnnestRel create(org.apache.calcite.rel.core.Correlate correlateRel, PlannerContext plannerContext)
      Create an instance from a Correlate that is based on a DruidRel and a DruidUnnestRel inputs.
    • getPartialDruidQuery

      @Nullable public PartialDruidQuery getPartialDruidQuery()
      Description copied from class: DruidRel
      Returns the PartialDruidQuery associated with this DruidRel, and which can be built on top of. Returns null if this rel cannot be built on top of.
      Specified by:
      getPartialDruidQuery in class DruidRel<DruidCorrelateUnnestRel>
    • withPartialQuery

      public DruidCorrelateUnnestRel withPartialQuery(PartialDruidQuery newQueryBuilder)
      Specified by:
      withPartialQuery in class DruidRel<DruidCorrelateUnnestRel>
    • toDruidQuery

      public DruidQuery toDruidQuery(boolean finalizeAggregations)
      Description copied from class: DruidRel
      Convert this DruidRel to a DruidQuery. This must be an inexpensive operation, since it is done often throughout query planning. This method must not return null.
      Specified by:
      toDruidQuery in class DruidRel<DruidCorrelateUnnestRel>
      Parameters:
      finalizeAggregations - true if this query should include explicit finalization for all of its aggregators, where required. Useful for subqueries where Druid's native query layer does not do this automatically.
    • deriveRowType

      protected org.apache.calcite.rel.type.RelDataType deriveRowType()
      Overrides:
      deriveRowType in class org.apache.calcite.rel.AbstractRelNode
    • toDruidQueryForExplaining

      public DruidQuery toDruidQueryForExplaining()
      Description copied from class: DruidRel
      Convert this DruidRel to a DruidQuery for purposes of explaining. This must be an inexpensive operation. This method must not return null.
      Specified by:
      toDruidQueryForExplaining in class DruidRel<DruidCorrelateUnnestRel>
    • explainTerms

      public org.apache.calcite.rel.RelWriter explainTerms(org.apache.calcite.rel.RelWriter pw)
      Description copied from class: DruidRel
      Overridden to ensure that subclasses provide a proper implementation. The default implementation from AbstractRelNode does nothing and is not appropriate.
      Overrides:
      explainTerms in class DruidRel<DruidCorrelateUnnestRel>
    • asDruidConvention

      public DruidCorrelateUnnestRel asDruidConvention()
      Description copied from class: DruidRel
      Returns a copy of this rel with the DruidConvention trait.
      Specified by:
      asDruidConvention in class DruidRel<DruidCorrelateUnnestRel>
    • getInputs

      public List<org.apache.calcite.rel.RelNode> getInputs()
      Specified by:
      getInputs in interface org.apache.calcite.rel.RelNode
      Specified by:
      getInputs in interface org.apache.calcite.plan.RelOptNode
      Overrides:
      getInputs in class org.apache.calcite.rel.AbstractRelNode
    • copy

      public org.apache.calcite.rel.RelNode copy(org.apache.calcite.plan.RelTraitSet traitSet, List<org.apache.calcite.rel.RelNode> inputs)
      Specified by:
      copy in interface org.apache.calcite.rel.RelNode
      Overrides:
      copy in class org.apache.calcite.rel.AbstractRelNode
    • computeSelfCost

      public org.apache.calcite.plan.RelOptCost computeSelfCost(org.apache.calcite.plan.RelOptPlanner planner, org.apache.calcite.rel.metadata.RelMetadataQuery mq)
      Specified by:
      computeSelfCost in interface org.apache.calcite.rel.RelNode
      Overrides:
      computeSelfCost in class org.apache.calcite.rel.AbstractRelNode
    • getDataSourceNames

      public Set<String> getDataSourceNames()
      Description copied from class: DruidRel
      Get the set of names of table datasources read by this DruidRel
      Specified by:
      getDataSourceNames in class DruidRel<DruidCorrelateUnnestRel>
    • computeLeftRequiresSubquery

      public static boolean computeLeftRequiresSubquery(DruidRel<?> left)
      Computes whether a particular left-side rel requires a subquery, or if we can operate on its underlying datasource directly.

      Stricter than DruidJoinQueryRel.computeLeftRequiresSubquery(org.apache.druid.sql.calcite.planner.PlannerContext, org.apache.druid.sql.calcite.rel.DruidRel<?>, org.apache.calcite.rel.core.Join): this method only allows scans (not mappings). This is OK because any mapping or other simple projection would have been pulled above the Correlate by DruidCorrelateUnnestRule.