Class DruidUnnestRule

java.lang.Object
org.apache.calcite.plan.RelOptRule
org.apache.druid.sql.calcite.rule.DruidUnnestRule

public class DruidUnnestRule extends org.apache.calcite.plan.RelOptRule
This class creates the rule to abide by for creating unnest (internally uncollect) in Calcite. Typically, Calcite plans the *unnest* part of the query involving a table such as
 SELECT * from numFoo, unnest(dim3)
 
or even a standalone unnest query such as
 SELECT * from unnest(ARRAY[1,2,3]) in the following way:
   78:Uncollect(subset=[rel#79:Subset#3.NONE.[]])
     76:LogicalProject(subset=[rel#77:Subset#2.NONE.[]], EXPR$0=[MV_TO_ARRAY($cor0.dim3)])
       7:LogicalValues(subset=[rel#75:Subset#1.NONE.[0]], tuples=[[{ 0 }]])
 
Calcite tackles plans bottom up. Therefore, DruidLogicalValuesRule converts the LogicalValues part into a leaf level DruidQueryRel thereby creating the following subtree in the call tree
 Uncollect
  \
  LogicalProject
   \
   DruidQueryRel
 
This forms the premise of this rule. The goal is to transform the above-mentioned structure in the tree with a new rel DruidUnnestRel which shall be created here.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.calcite.plan.RelOptRule

    org.apache.calcite.plan.RelOptRule.ConverterRelOptRuleOperand
  • Field Summary

    Fields inherited from class org.apache.calcite.plan.RelOptRule

    description, operands, relBuilderFactory
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    matches(org.apache.calcite.plan.RelOptRuleCall call)
     
    void
    onMatch(org.apache.calcite.plan.RelOptRuleCall call)
     

    Methods inherited from class org.apache.calcite.plan.RelOptRule

    any, convert, convert, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DruidUnnestRule

      public DruidUnnestRule(PlannerContext plannerContext)
  • Method Details

    • matches

      public boolean matches(org.apache.calcite.plan.RelOptRuleCall call)
      Overrides:
      matches in class org.apache.calcite.plan.RelOptRule
    • onMatch

      public void onMatch(org.apache.calcite.plan.RelOptRuleCall call)
      Specified by:
      onMatch in class org.apache.calcite.plan.RelOptRule