Package org.apache.calcite.prepare
Class Prepare
java.lang.Object
org.apache.calcite.prepare.Prepare
- Direct Known Subclasses:
CalcitePrepareImpl.CalcitePreparingStmt
Abstract base for classes that implement
the process of preparing and executing SQL expressions.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Abstract implementation ofPrepare.PreparingTable
with an implementation forPrepare.AbstractPreparingTable.columnHasDefaultValue(org.apache.calcite.rel.type.RelDataType, int, org.apache.calcite.sql2rel.InitializerContext)
.static interface
Interface by which validator and planner can read table metadata.static class
Describes that a given SQL query is materialized by a given table.static class
PreparedExplanation is a PreparedResult for an EXPLAIN PLAN statement.static interface
static class
Abstract implementation ofPrepare.PreparedResult
.static interface
Definition of a table, for the purposes of the validator and planner. -
Field Summary
Modifier and TypeFieldDescriptionprotected final Prepare.CatalogReader
protected final CalcitePrepare.Context
protected static final org.slf4j.Logger
protected @MonotonicNonNull RelDataType
protected final Convention
Convention via which results should be returned by execution.static final TryThreadLocal<Boolean>
Temporary, until [CALCITE-1045] Decorrelate sub-queries in Project and Join is fixed.static final TryThreadLocal<@Nullable Integer>
static final TryThreadLocal<Boolean>
protected @Nullable CalciteTimingTracer
-
Constructor Summary
ModifierConstructorDescriptionprotected
Prepare
(CalcitePrepare.Context context, Prepare.CatalogReader catalogReader, Convention resultConvention) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Prepare.PreparedResult
createPreparedExplanation
(@Nullable RelDataType resultType, RelDataType parameterRowType, @Nullable RelRoot root, SqlExplainFormat format, SqlExplainLevel detailLevel) protected abstract RelNode
decorrelate
(SqlToRelConverter sqlToRelConverter, SqlNode query, RelNode rootRel) abstract RelNode
flattenTypes
(RelNode rootRel, boolean restructure) protected RelTraitSet
protected abstract List<CalciteSchema.LatticeEntry>
protected abstract List<Prepare.Materialization>
protected Program
protected abstract SqlToRelConverter
getSqlToRelConverter
(SqlValidator validator, Prepare.CatalogReader catalogReader, SqlToRelConverter.Config config) Protected method to allow subclasses to override construction of SqlToRelConverter.protected abstract SqlValidator
protected abstract Prepare.PreparedResult
Implements a physical query plan.protected abstract void
protected @Nullable TableModify.Operation
mapTableModOp
(boolean isDml, SqlKind sqlKind) protected RelRoot
optimize
(RelRoot root, List<Prepare.Materialization> materializations, List<CalciteSchema.LatticeEntry> lattices) Optimizes a query plan.prepareSql
(SqlNode sqlQuery, Class runtimeContextClass, SqlValidator validator, boolean needsValidation) prepareSql
(SqlNode sqlQuery, SqlNode sqlNodeOriginal, Class runtimeContextClass, SqlValidator validator, boolean needsValidation) protected RelRoot
trimUnusedFields
(RelRoot root) Walks over a tree of relational expressions, replacing eachRelNode
with a 'slimmed down' relational expression that projects only the columns required by its consumer.
-
Field Details
-
LOGGER
protected static final org.slf4j.Logger LOGGER -
context
-
catalogReader
-
resultConvention
Convention via which results should be returned by execution. -
timingTracer
-
fieldOrigins
-
parameterRowType
-
THREAD_TRIM
-
THREAD_EXPAND
Temporary, until [CALCITE-1045] Decorrelate sub-queries in Project and Join is fixed.The default is false, meaning do not expand queries during sql-to-rel, but a few tests override and set it to true. After CALCITE-1045 is fixed, remove those overrides and use false everywhere.
-
THREAD_INSUBQUERY_THRESHOLD
-
-
Constructor Details
-
Prepare
protected Prepare(CalcitePrepare.Context context, Prepare.CatalogReader catalogReader, Convention resultConvention)
-
-
Method Details
-
createPreparedExplanation
protected abstract Prepare.PreparedResult createPreparedExplanation(@Nullable RelDataType resultType, RelDataType parameterRowType, @Nullable RelRoot root, SqlExplainFormat format, SqlExplainLevel detailLevel) -
optimize
protected RelRoot optimize(RelRoot root, List<Prepare.Materialization> materializations, List<CalciteSchema.LatticeEntry> lattices) Optimizes a query plan.- Parameters:
root
- Root of relational expression treematerializations
- Tables known to be populated with a given querylattices
- Lattices- Returns:
- an equivalent optimized relational expression
-
getProgram
-
getDesiredRootTraitSet
-
implement
Implements a physical query plan.- Parameters:
root
- Root of the relational expression tree- Returns:
- an executable plan
-
prepareSql
public Prepare.PreparedResult prepareSql(SqlNode sqlQuery, Class runtimeContextClass, SqlValidator validator, boolean needsValidation) -
prepareSql
public Prepare.PreparedResult prepareSql(SqlNode sqlQuery, SqlNode sqlNodeOriginal, Class runtimeContextClass, SqlValidator validator, boolean needsValidation) -
mapTableModOp
-
getSqlToRelConverter
protected abstract SqlToRelConverter getSqlToRelConverter(SqlValidator validator, Prepare.CatalogReader catalogReader, SqlToRelConverter.Config config) Protected method to allow subclasses to override construction of SqlToRelConverter. -
flattenTypes
-
decorrelate
protected abstract RelNode decorrelate(SqlToRelConverter sqlToRelConverter, SqlNode query, RelNode rootRel) -
getMaterializations
-
getLattices
-
trimUnusedFields
Walks over a tree of relational expressions, replacing eachRelNode
with a 'slimmed down' relational expression that projects only the columns required by its consumer.- Parameters:
root
- Root of relational expression tree- Returns:
- Trimmed relational expression
-
init
-
getSqlValidator
-