Package org.apache.calcite.prepare
Class PlannerImpl
java.lang.Object
org.apache.calcite.prepare.PlannerImpl
- All Implemented Interfaces:
AutoCloseable
,RelOptTable.ViewExpander
,Planner
Implementation of
Planner
.-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Releases all internal resources utilized while thisPlanner
exists.final RelNode
expandView
(RelDataType rowType, String queryString, List<String> schemaPath, @Nullable List<String> viewPath) Returns a relational expression that is to be substituted for an access to a SQL view.Returns a record type that contains the name and type of each parameter.Returns the type factory.Parses and validates a SQL statement.Converts a SQL parse tree into a tree of relational expressions.void
reset()
Resets thisPlanner
to be used with a new query.transform
(int ruleSetIndex, RelTraitSet requiredOutputTraits, RelNode rel) Converts one relational expression tree into another relational expression based on a particular rule set and requires set of traits.Validates a SQL statement.validateAndGetType
(SqlNode sqlNode) Validates a SQL statement.
-
Constructor Details
-
PlannerImpl
Creates a planner. Not a public API; callFrameworks.getPlanner(org.apache.calcite.tools.FrameworkConfig)
instead.
-
-
Method Details
-
getEmptyTraitSet
- Specified by:
getEmptyTraitSet
in interfacePlanner
-
close
public void close()Description copied from interface:Planner
Releases all internal resources utilized while thisPlanner
exists. Once called, this Planner object is no longer valid.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacePlanner
-
reset
public void reset()Description copied from interface:Planner
Resets thisPlanner
to be used with a new query. This should be called between each new query. -
parse
Description copied from interface:Planner
Parses and validates a SQL statement.- Specified by:
parse
in interfacePlanner
- 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
Description copied from interface:Planner
Validates a SQL statement.- Specified by:
validate
in interfacePlanner
- Parameters:
sqlNode
- Root node of the SQL parse tree.- Returns:
- Validated node
- Throws:
ValidationException
- if not valid
-
validateAndGetType
Description copied from interface:Planner
Validates a SQL statement.- Specified by:
validateAndGetType
in interfacePlanner
- Parameters:
sqlNode
- Root node of the SQL parse tree.- Returns:
- Validated node and its validated type.
- Throws:
ValidationException
- if not valid
-
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 interfacePlanner
- Returns:
- Record type
-
convert
-
rel
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. -
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 interfaceRelOptTable.ViewExpander
- Parameters:
rowType
- Row type of the viewqueryString
- Body of the viewschemaPath
- Path of a schema wherein to find referenced tablesviewPath
- Path of the view, ending with its name; may be null- Returns:
- Relational expression
-
getTypeFactory
Description copied from interface:Planner
Returns the type factory.- Specified by:
getTypeFactory
in interfacePlanner
-
transform
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 interfacePlanner
- 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.
-
PlannerImpl
implementsRelOptTable.ViewExpander
directly.