Implementation of org.apache.calcite.tools.Planner.
| 71 | |
| 72 | /** Implementation of {@link org.apache.calcite.tools.Planner}. */ |
| 73 | public class PlannerImpl implements Planner, ViewExpander { |
| 74 | private final SqlOperatorTable operatorTable; |
| 75 | private final ImmutableList<Program> programs; |
| 76 | private final @Nullable RelOptCostFactory costFactory; |
| 77 | private final Context context; |
| 78 | private final CalciteConnectionConfig connectionConfig; |
| 79 | private final RelDataTypeSystem typeSystem; |
| 80 | |
| 81 | /** Holds the trait definitions to be registered with planner. May be null. */ |
| 82 | private final @Nullable ImmutableList<RelTraitDef> traitDefs; |
| 83 | |
| 84 | private final SqlParser.Config parserConfig; |
| 85 | private final SqlValidator.Config sqlValidatorConfig; |
| 86 | private final SqlToRelConverter.Config sqlToRelConverterConfig; |
| 87 | private final SqlRexConvertletTable convertletTable; |
| 88 | |
| 89 | private State state; |
| 90 | |
| 91 | // set in STATE_1_RESET |
| 92 | @SuppressWarnings("unused") |
| 93 | private boolean open; |
| 94 | |
| 95 | // set in STATE_2_READY |
| 96 | private final @Nullable SchemaPlus defaultSchema; |
| 97 | private @Nullable JavaTypeFactory typeFactory; |
| 98 | private @Nullable RelOptPlanner planner; |
| 99 | private final @Nullable RexExecutor executor; |
| 100 | |
| 101 | // set in STATE_4_VALIDATE |
| 102 | private @Nullable SqlValidator validator; |
| 103 | private @Nullable SqlNode validatedSqlNode; |
| 104 | |
| 105 | /** Creates a planner. Not a public API; call |
| 106 | * {@link org.apache.calcite.tools.Frameworks#getPlanner} instead. */ |
| 107 | @SuppressWarnings("method.invocation.invalid") |
| 108 | public PlannerImpl(FrameworkConfig config) { |
| 109 | this.costFactory = config.getCostFactory(); |
| 110 | this.defaultSchema = config.getDefaultSchema(); |
| 111 | this.operatorTable = config.getOperatorTable(); |
| 112 | this.programs = config.getPrograms(); |
| 113 | this.parserConfig = config.getParserConfig(); |
| 114 | this.sqlValidatorConfig = config.getSqlValidatorConfig(); |
| 115 | this.sqlToRelConverterConfig = config.getSqlToRelConverterConfig(); |
| 116 | this.state = State.STATE_0_CLOSED; |
| 117 | this.traitDefs = config.getTraitDefs(); |
| 118 | this.convertletTable = config.getConvertletTable(); |
| 119 | this.executor = config.getExecutor(); |
| 120 | this.context = config.getContext(); |
| 121 | this.connectionConfig = connConfig(context, parserConfig); |
| 122 | this.typeSystem = config.getTypeSystem(); |
| 123 | reset(); |
| 124 | } |
| 125 | |
| 126 | /** Gets a user-defined config and appends default connection values. */ |
| 127 | private static CalciteConnectionConfig connConfig(Context context, |
| 128 | SqlParser.Config parserConfig) { |
| 129 | CalciteConnectionConfigImpl config = |
| 130 | context.maybeUnwrap(CalciteConnectionConfigImpl.class) |
nothing calls this directly
no outgoing calls
no test coverage detected