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
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
static class
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultSqlHandler
(SqlHandlerConfig config) DefaultSqlHandler
(SqlHandlerConfig config, Pointer<String> textPlan) -
Method Summary
Modifier and TypeMethodDescriptionprotected DrillRel
addRenamedProject
(DrillRel rel, org.apache.calcite.rel.type.RelDataType validatedRowType) protected DrillRel
convertToDrel
(org.apache.calcite.rel.RelNode relNode) Return Drill Logical RelNode tree for a SELECT statement, when it is executed / explained directly.protected PhysicalPlan
convertToPlan
(PhysicalOperator op, org.apache.calcite.rel.RelNode queryRelNode) protected PhysicalOperator
convertToPop
(Prel prel) protected Prel
convertToPrel
(org.apache.calcite.rel.RelNode drel, org.apache.calcite.rel.type.RelDataType validatedRowType) Applies physical rules and certain transformations to convert drill relational node into physical one.protected DrillRel
convertToRawDrel
(org.apache.calcite.rel.RelNode relNode) Given a relNode tree for SELECT statement, convert to Drill Logical RelNode tree.getPlan
(org.apache.calcite.sql.SqlNode sqlNode) static List<PhysicalOperator>
getPops
(PhysicalOperator root) 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) protected void
log
(String name, PhysicalPlan plan, org.slf4j.Logger logger) 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) protected void
logAndSetTextPlan
(String description, Prel prel, org.slf4j.Logger logger) protected org.apache.calcite.sql.SqlNode
rewrite
(org.apache.calcite.sql.SqlNode node) Rewrite the parse tree.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.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.protected DefaultSqlHandler.ConvertedRelNode
validateAndConvert
(org.apache.calcite.sql.SqlNode sqlNode) protected org.apache.calcite.util.Pair<org.apache.calcite.sql.SqlNode,
org.apache.calcite.rel.type.RelDataType> validateNode
(org.apache.calcite.sql.SqlNode sqlNode) Methods inherited from class org.apache.drill.exec.planner.sql.handlers.AbstractSqlHandler
unwrap
-
Field Details
-
config
-
context
-
-
Constructor Details
-
DefaultSqlHandler
-
DefaultSqlHandler
-
-
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
-
log
-
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 classAbstractSqlHandler
- 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 RelNodetargetTraits
- 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 RelNodetargetTraits
- 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 nodevalidatedRowType
- final output row type- Returns:
- physical relational node
- Throws:
org.apache.calcite.tools.RelConversionException
SqlUnsupportedException
-
convertToPop
- Throws:
IOException
-
convertToPlan
protected PhysicalPlan convertToPlan(PhysicalOperator op, org.apache.calcite.rel.RelNode queryRelNode) -
getPops
-
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
-