Class CalcitePlanner

java.lang.Object
org.apache.druid.sql.calcite.planner.CalcitePlanner
All Implemented Interfaces:
AutoCloseable, org.apache.calcite.plan.RelOptTable.ViewExpander, org.apache.calcite.tools.Planner

public class CalcitePlanner extends Object implements org.apache.calcite.tools.Planner, org.apache.calcite.plan.RelOptTable.ViewExpander
Calcite planner. Clone of Calcite's PlannerImpl, as of version 1.35, but with the validator made accessible, and with the minimum of formatting changes needed to pass Druid's static checks. Note that the resulting code is more Calcite-like than Druid-like. There seemed no value in restructuring the code just to be more Druid-like. Changes in 1.35: Allowing user-defined config and appending default values to the config frameworkConfig is now replaced by costFactory
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Deprecated.
    Now CalcitePlanner implements RelOptTable.ViewExpander directly.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CalcitePlanner(org.apache.calcite.tools.FrameworkConfig config)
    Creates a planner.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    final org.apache.calcite.rel.RelNode
    convert(org.apache.calcite.sql.SqlNode sql)
     
    org.apache.calcite.rel.RelRoot
    expandView(org.apache.calcite.rel.type.RelDataType rowType, String queryString, List<String> schemaPath, List<String> viewPath)
     
    org.apache.calcite.plan.RelTraitSet
     
    org.apache.calcite.rel.type.RelDataType
     
    org.apache.calcite.adapter.java.JavaTypeFactory
     
    org.apache.calcite.sql.validate.SqlValidator
     
    org.apache.calcite.sql.SqlNode
    parse(Reader reader)
     
    org.apache.calcite.rel.RelRoot
    rel(org.apache.calcite.sql.SqlNode sql)
     
    void
     
    void
    Skip parsing, moving state along to a CalcitePlanner.State.STATE_3_PARSED.
    org.apache.calcite.rel.RelNode
    transform(int ruleSetIndex, org.apache.calcite.plan.RelTraitSet requiredOutputTraits, org.apache.calcite.rel.RelNode rel)
     
    org.apache.calcite.sql.SqlNode
    validate(org.apache.calcite.sql.SqlNode sqlNode)
     
    org.apache.calcite.util.Pair<org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType>
    validateAndGetType(org.apache.calcite.sql.SqlNode sqlNode)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.calcite.tools.Planner

    parse
  • Constructor Details

    • CalcitePlanner

      public CalcitePlanner(org.apache.calcite.tools.FrameworkConfig config)
      Creates a planner. Not a public API; call Frameworks.getPlanner(org.apache.calcite.tools.FrameworkConfig) instead.
  • Method Details

    • getEmptyTraitSet

      public org.apache.calcite.plan.RelTraitSet getEmptyTraitSet()
      Specified by:
      getEmptyTraitSet in interface org.apache.calcite.tools.Planner
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.apache.calcite.tools.Planner
    • reset

      public void reset()
      Specified by:
      reset in interface org.apache.calcite.tools.Planner
    • parse

      public org.apache.calcite.sql.SqlNode parse(Reader reader) throws org.apache.calcite.sql.parser.SqlParseException
      Specified by:
      parse in interface org.apache.calcite.tools.Planner
      Throws:
      org.apache.calcite.sql.parser.SqlParseException
    • skipParse

      public void skipParse()
      Skip parsing, moving state along to a CalcitePlanner.State.STATE_3_PARSED. We have this because we parse before the planner is even created, using DruidSqlParser, in order to capture SET statements as early as possible.
    • validate

      public org.apache.calcite.sql.SqlNode validate(org.apache.calcite.sql.SqlNode sqlNode) throws org.apache.calcite.tools.ValidationException
      Specified by:
      validate in interface org.apache.calcite.tools.Planner
      Throws:
      org.apache.calcite.tools.ValidationException
    • getValidator

      public org.apache.calcite.sql.validate.SqlValidator getValidator()
    • validateAndGetType

      public org.apache.calcite.util.Pair<org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType> validateAndGetType(org.apache.calcite.sql.SqlNode sqlNode) throws org.apache.calcite.tools.ValidationException
      Specified by:
      validateAndGetType in interface org.apache.calcite.tools.Planner
      Throws:
      org.apache.calcite.tools.ValidationException
    • getParameterRowType

      public org.apache.calcite.rel.type.RelDataType getParameterRowType()
      Specified by:
      getParameterRowType in interface org.apache.calcite.tools.Planner
    • convert

      public final org.apache.calcite.rel.RelNode convert(org.apache.calcite.sql.SqlNode sql)
      Specified by:
      convert in interface org.apache.calcite.tools.Planner
    • rel

      public org.apache.calcite.rel.RelRoot rel(org.apache.calcite.sql.SqlNode sql)
      Specified by:
      rel in interface org.apache.calcite.tools.Planner
    • expandView

      public org.apache.calcite.rel.RelRoot expandView(org.apache.calcite.rel.type.RelDataType rowType, String queryString, List<String> schemaPath, @Nullable List<String> viewPath)
      Specified by:
      expandView in interface org.apache.calcite.plan.RelOptTable.ViewExpander
    • getTypeFactory

      public org.apache.calcite.adapter.java.JavaTypeFactory getTypeFactory()
      Specified by:
      getTypeFactory in interface org.apache.calcite.tools.Planner
    • transform

      public org.apache.calcite.rel.RelNode transform(int ruleSetIndex, org.apache.calcite.plan.RelTraitSet requiredOutputTraits, org.apache.calcite.rel.RelNode rel)
      Specified by:
      transform in interface org.apache.calcite.tools.Planner