Class PlannerImpl

java.lang.Object
org.apache.calcite.prepare.PlannerImpl
All Implemented Interfaces:
AutoCloseable, RelOptTable.ViewExpander, Planner

public class PlannerImpl extends Object implements Planner, RelOptTable.ViewExpander
Implementation of Planner.
  • Constructor Details

  • Method Details

    • getEmptyTraitSet

      public RelTraitSet getEmptyTraitSet()
      Specified by:
      getEmptyTraitSet in interface Planner
    • close

      public void close()
      Description copied from interface: Planner
      Releases all internal resources utilized while this Planner exists. Once called, this Planner object is no longer valid.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Planner
    • reset

      public void reset()
      Description copied from interface: Planner
      Resets this Planner to be used with a new query. This should be called between each new query.
      Specified by:
      reset in interface Planner
    • parse

      public SqlNode parse(Reader reader) throws SqlParseException
      Description copied from interface: Planner
      Parses and validates a SQL statement.
      Specified by:
      parse in interface Planner
      Parameters:
      reader - A reader which will provide the SQL statement to parse.
      Returns:
      The root node of the SQL parse tree.
      Throws:
      SqlParseException - on parse error
    • validate

      @EnsuresNonNull("validator") public SqlNode validate(SqlNode sqlNode) throws ValidationException
      Description copied from interface: Planner
      Validates a SQL statement.
      Specified by:
      validate in interface Planner
      Parameters:
      sqlNode - Root node of the SQL parse tree.
      Returns:
      Validated node
      Throws:
      ValidationException - if not valid
    • validateAndGetType

      public Pair<SqlNode,RelDataType> validateAndGetType(SqlNode sqlNode) throws ValidationException
      Description copied from interface: Planner
      Validates a SQL statement.
      Specified by:
      validateAndGetType in interface Planner
      Parameters:
      sqlNode - Root node of the SQL parse tree.
      Returns:
      Validated node and its validated type.
      Throws:
      ValidationException - if not valid
    • getParameterRowType

      public RelDataType getParameterRowType()
      Description copied from interface: Planner
      Returns a record type that contains the name and type of each parameter. Returns a record type with no fields if there are no parameters.
      Specified by:
      getParameterRowType in interface Planner
      Returns:
      Record type
    • convert

      public final RelNode convert(SqlNode sql)
      Specified by:
      convert in interface Planner
    • rel

      public RelRoot rel(SqlNode sql)
      Description copied from interface: Planner
      Converts a SQL parse tree into a tree of relational expressions.

      You must call Planner.validate(org.apache.calcite.sql.SqlNode) first.

      Specified by:
      rel in interface Planner
      Parameters:
      sql - The root node of the SQL parse tree.
      Returns:
      The root node of the newly generated RelNode tree.
    • expandView

      public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath, @Nullable List<String> viewPath)
      Description copied from interface: RelOptTable.ViewExpander
      Returns a relational expression that is to be substituted for an access to a SQL view.
      Specified by:
      expandView in interface RelOptTable.ViewExpander
      Parameters:
      rowType - Row type of the view
      queryString - Body of the view
      schemaPath - Path of a schema wherein to find referenced tables
      viewPath - Path of the view, ending with its name; may be null
      Returns:
      Relational expression
    • getTypeFactory

      public JavaTypeFactory getTypeFactory()
      Description copied from interface: Planner
      Returns the type factory.
      Specified by:
      getTypeFactory in interface Planner
    • transform

      public RelNode transform(int ruleSetIndex, RelTraitSet requiredOutputTraits, RelNode rel)
      Description copied from interface: Planner
      Converts one relational expression tree into another relational expression based on a particular rule set and requires set of traits.
      Specified by:
      transform in interface Planner
      Parameters:
      ruleSetIndex - The RuleSet to use for conversion purposes. Note that this is zero-indexed and is based on the list and order of RuleSets provided in the construction of this Planner.
      requiredOutputTraits - The set of RelTraits required of the root node at the termination of the planning cycle.
      rel - The root of the RelNode tree to convert.
      Returns:
      The root of the new RelNode tree.