Class DefaultSqlHandler

java.lang.Object
org.apache.drill.exec.planner.sql.handlers.AbstractSqlHandler
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler
Direct Known Subclasses:
AnalyzeTableHandler, BaseAliasHandler, CreateFunctionHandler, CreateTableHandler, DescribeSchemaHandler, DescribeTableHandler, DropFunctionHandler, DropTableHandler, ExplainHandler, InsertHandler, MetastoreAnalyzeTableHandler, MetastoreDropTableMetadataHandler, RefreshMetadataHandler, SchemaHandler, ShowFilesHandler, ShowSchemasHandler, ShowTablesHandler, ViewHandler

public class DefaultSqlHandler extends AbstractSqlHandler
  • Field Details

  • Constructor Details

  • Method Details

    • log

      protected void log(PlannerType plannerType, PlannerPhase phase, org.apache.calcite.rel.RelNode node, org.slf4j.Logger logger, org.apache.drill.shaded.guava.com.google.common.base.Stopwatch watch)
    • log

      protected void log(String description, org.apache.calcite.rel.RelNode node, org.slf4j.Logger logger, org.apache.drill.shaded.guava.com.google.common.base.Stopwatch watch)
    • logAndSetTextPlan

      protected void logAndSetTextPlan(String description, Prel prel, org.slf4j.Logger logger)
    • log

      protected void log(String name, PhysicalPlan plan, org.slf4j.Logger logger)
    • getPlan

      public PhysicalPlan getPlan(org.apache.calcite.sql.SqlNode sqlNode) throws org.apache.calcite.tools.ValidationException, org.apache.calcite.tools.RelConversionException, IOException, ForemanSetupException
      Specified by:
      getPlan in class AbstractSqlHandler
      Throws:
      org.apache.calcite.tools.ValidationException
      org.apache.calcite.tools.RelConversionException
      IOException
      ForemanSetupException
    • rewrite

      protected org.apache.calcite.sql.SqlNode rewrite(org.apache.calcite.sql.SqlNode node) throws org.apache.calcite.tools.RelConversionException, ForemanSetupException
      Rewrite the parse tree. Used before validating the parse tree. Useful if a particular statement needs to converted into another statement.
      Parameters:
      node - sql parse tree to be rewritten
      Returns:
      Rewritten sql parse tree
      Throws:
      org.apache.calcite.tools.RelConversionException
      ForemanSetupException
    • validateAndConvert

      protected DefaultSqlHandler.ConvertedRelNode validateAndConvert(org.apache.calcite.sql.SqlNode sqlNode) throws ForemanSetupException, org.apache.calcite.tools.RelConversionException, org.apache.calcite.tools.ValidationException
      Throws:
      ForemanSetupException
      org.apache.calcite.tools.RelConversionException
      org.apache.calcite.tools.ValidationException
    • convertToRawDrel

      protected DrillRel convertToRawDrel(org.apache.calcite.rel.RelNode relNode) throws SqlUnsupportedException
      Given a relNode tree for SELECT statement, convert to Drill Logical RelNode tree.
      Parameters:
      relNode - relational node
      Returns:
      Drill Logical RelNode tree
      Throws:
      SqlUnsupportedException - if query cannot be planned
    • convertToDrel

      protected DrillRel convertToDrel(org.apache.calcite.rel.RelNode relNode) throws SqlUnsupportedException
      Return Drill Logical RelNode tree for a SELECT statement, when it is executed / explained directly. Adds screen operator on top of converted node.
      Parameters:
      relNode - root RelNode corresponds to Calcite Logical RelNode.
      Returns:
      Drill Logical RelNode tree
      Throws:
      SqlUnsupportedException - if query cannot be planned
    • transform

      protected org.apache.calcite.rel.RelNode transform(PlannerType plannerType, PlannerPhase phase, org.apache.calcite.rel.RelNode input, org.apache.calcite.plan.RelTraitSet targetTraits)
      Transform RelNode to a new RelNode, targeting the provided set of traits. Also will log the outcome.
      Parameters:
      plannerType - The type of Planner to use.
      phase - The transformation phase we're running.
      input - The original RelNode
      targetTraits - The traits we are targeting for output.
      Returns:
      The transformed relnode.
    • transform

      protected org.apache.calcite.rel.RelNode transform(PlannerType plannerType, PlannerPhase phase, org.apache.calcite.rel.RelNode input, org.apache.calcite.plan.RelTraitSet targetTraits, boolean log)
      Transform RelNode to a new RelNode, targeting the provided set of traits. Also will log the outcome if asked.
      Parameters:
      plannerType - The type of Planner to use.
      phase - The transformation phase we're running.
      input - The original RelNode
      targetTraits - The traits we are targeting for output.
      log - Whether to log the planning phase.
      Returns:
      The transformed relnode.
    • convertToPrel

      protected Prel convertToPrel(org.apache.calcite.rel.RelNode drel, org.apache.calcite.rel.type.RelDataType validatedRowType) throws org.apache.calcite.tools.RelConversionException, SqlUnsupportedException
      Applies physical rules and certain transformations to convert drill relational node into physical one.
      Parameters:
      drel - relational node
      validatedRowType - final output row type
      Returns:
      physical relational node
      Throws:
      org.apache.calcite.tools.RelConversionException
      SqlUnsupportedException
    • convertToPop

      protected PhysicalOperator convertToPop(Prel prel) throws IOException
      Throws:
      IOException
    • convertToPlan

      protected PhysicalPlan convertToPlan(PhysicalOperator op, org.apache.calcite.rel.RelNode queryRelNode)
    • getPops

      public static List<PhysicalOperator> getPops(PhysicalOperator root)
    • validateNode

      protected org.apache.calcite.util.Pair<org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType> validateNode(org.apache.calcite.sql.SqlNode sqlNode) throws org.apache.calcite.tools.ValidationException, org.apache.calcite.tools.RelConversionException, ForemanSetupException
      Throws:
      org.apache.calcite.tools.ValidationException
      org.apache.calcite.tools.RelConversionException
      ForemanSetupException
    • addRenamedProject

      protected DrillRel addRenamedProject(DrillRel rel, org.apache.calcite.rel.type.RelDataType validatedRowType)