final RelDataType x;
final Prepare.PreparedResult preparedResult;
if (sql != null) {
assert queryable == null;
final OptiqConnectionConfig config = context.config();
SqlParser parser = SqlParser.create(SqlParserImpl.FACTORY, sql,
config.quoting(), config.unquotedCasing(), config.quotedCasing());
SqlNode sqlNode;
try {
sqlNode = parser.parseStmt();
} catch (SqlParseException e) {
throw new RuntimeException(
"parse failed: " + e.getMessage(), e);
}
Hook.PARSE_TREE.run(new Object[] {sql, sqlNode});
final OptiqSchema rootSchema = context.getRootSchema();
final ChainedSqlOperatorTable opTab =
new ChainedSqlOperatorTable(
ImmutableList.of(SqlStdOperatorTable.instance(), catalogReader));
final SqlValidator validator =
new OptiqSqlValidator(opTab, catalogReader, typeFactory);
validator.setIdentifierExpansion(true);
final List<Prepare.Materialization> materializations =
config.materializationsEnabled()
? MaterializationService.instance().query(rootSchema)
: ImmutableList.<Prepare.Materialization>of();
for (Prepare.Materialization materialization : materializations) {
populateMaterializations(context, planner, materialization);
}