public class PlannerImpl extends java.lang.Object implements Planner, RelOptTable.ViewExpander
Planner
.Modifier and Type | Class and Description |
---|---|
private static class |
PlannerImpl.State
Stage of a statement in the query-preparation lifecycle.
|
class |
PlannerImpl.ViewExpanderImpl
Deprecated.
Now
PlannerImpl implements RelOptTable.ViewExpander
directly. |
Modifier and Type | Field and Description |
---|---|
private CalciteConnectionConfig |
connectionConfig |
private Context |
context |
private SqlRexConvertletTable |
convertletTable |
private SchemaPlus |
defaultSchema |
private RexExecutor |
executor |
private FrameworkConfig |
frameworkConfig |
private boolean |
open |
private SqlOperatorTable |
operatorTable |
private SqlParser.Config |
parserConfig |
private RelOptPlanner |
planner |
private com.google.common.collect.ImmutableList<Program> |
programs |
private RelRoot |
root |
private SqlToRelConverter.Config |
sqlToRelConverterConfig |
private PlannerImpl.State |
state |
private com.google.common.collect.ImmutableList<RelTraitDef> |
traitDefs
Holds the trait definitions to be registered with planner.
|
private JavaTypeFactory |
typeFactory |
private SqlNode |
validatedSqlNode |
private SqlValidator |
validator |
Constructor and Description |
---|
PlannerImpl(FrameworkConfig config)
Creates a planner.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases all internal resources utilized while this
Planner
exists. |
private SqlConformance |
conformance() |
private CalciteConnectionConfig |
connConfig() |
RelNode |
convert(SqlNode sql) |
private CalciteCatalogReader |
createCatalogReader() |
private RexBuilder |
createRexBuilder() |
private void |
ensure(PlannerImpl.State state)
Makes sure that the state is at least the given state.
|
RelRoot |
expandView(RelDataType rowType,
java.lang.String queryString,
java.util.List<java.lang.String> schemaPath,
java.util.List<java.lang.String> viewPath)
Returns a relational expression that is to be substituted for an access
to a SQL view.
|
RelTraitSet |
getEmptyTraitSet() |
JavaTypeFactory |
getTypeFactory()
Returns the type factory.
|
SqlNode |
parse(java.io.Reader reader)
Parses and validates a SQL statement.
|
private void |
ready() |
RelRoot |
rel(SqlNode sql)
Converts a SQL parse tree into a tree of relational expressions.
|
void |
reset()
Resets this
Planner to be used with a new query. |
private static SchemaPlus |
rootSchema(SchemaPlus schema) |
RelNode |
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.
|
SqlNode |
validate(SqlNode sqlNode)
Validates a SQL statement.
|
Pair<SqlNode,RelDataType> |
validateAndGetType(SqlNode sqlNode)
Validates a SQL statement.
|
private final SqlOperatorTable operatorTable
private final com.google.common.collect.ImmutableList<Program> programs
private final FrameworkConfig frameworkConfig
private final Context context
private final CalciteConnectionConfig connectionConfig
private final com.google.common.collect.ImmutableList<RelTraitDef> traitDefs
private final SqlParser.Config parserConfig
private final SqlToRelConverter.Config sqlToRelConverterConfig
private final SqlRexConvertletTable convertletTable
private PlannerImpl.State state
private boolean open
private SchemaPlus defaultSchema
private JavaTypeFactory typeFactory
private RelOptPlanner planner
private RexExecutor executor
private SqlValidator validator
private SqlNode validatedSqlNode
private RelRoot root
public PlannerImpl(FrameworkConfig config)
Frameworks.getPlanner(org.apache.calcite.tools.FrameworkConfig)
instead.private CalciteConnectionConfig connConfig()
private void ensure(PlannerImpl.State state)
public RelTraitSet getEmptyTraitSet()
getEmptyTraitSet
in interface Planner
public void close()
Planner
Planner
exists. Once called, this Planner object is no longer valid.public void reset()
Planner
Planner
to be used with a new query. This
should be called between each new query.private void ready()
public SqlNode parse(java.io.Reader reader) throws SqlParseException
Planner
parse
in interface Planner
reader
- A reader which will provide the SQL statement to parse.SqlParseException
- on parse errorpublic SqlNode validate(SqlNode sqlNode) throws ValidationException
Planner
validate
in interface Planner
sqlNode
- Root node of the SQL parse tree.ValidationException
- if not validprivate SqlConformance conformance()
public Pair<SqlNode,RelDataType> validateAndGetType(SqlNode sqlNode) throws ValidationException
Planner
validateAndGetType
in interface Planner
sqlNode
- Root node of the SQL parse tree.ValidationException
- if not validpublic final RelNode convert(SqlNode sql) throws RelConversionException
convert
in interface Planner
RelConversionException
public RelRoot rel(SqlNode sql) throws RelConversionException
Planner
You must call Planner.validate(org.apache.calcite.sql.SqlNode)
first.
rel
in interface Planner
sql
- The root node of the SQL parse tree.RelConversionException
- if the node
cannot be converted or has not been validatedpublic RelRoot expandView(RelDataType rowType, java.lang.String queryString, java.util.List<java.lang.String> schemaPath, java.util.List<java.lang.String> viewPath)
RelOptTable.ViewExpander
expandView
in interface RelOptTable.ViewExpander
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 nullprivate CalciteCatalogReader createCatalogReader()
private static SchemaPlus rootSchema(SchemaPlus schema)
private RexBuilder createRexBuilder()
public JavaTypeFactory getTypeFactory()
Planner
getTypeFactory
in interface Planner
public RelNode transform(int ruleSetIndex, RelTraitSet requiredOutputTraits, RelNode rel) throws RelConversionException
Planner
transform
in interface Planner
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.RelConversionException
- on conversion
errorCopyright © 2012–2019 The Apache Software Foundation. All rights reserved.