SQLParser parser = server.getParser();
StatementNode insertStmt;
try {
insertStmt = parser.parseStatement("insert into " + newAIS.getTable(cs.getToTableId()).getName().toStringEscaped() + " " + cs.getSelectStatement());
} catch (StandardException e) {
throw new SQLParserInternalException(e);
}
StoreAdapter adapter = givenStore.createAdapter(session, SchemaCache.globalSchema(newAIS));
CreateAsCompiler compiler = new CreateAsCompiler(server, adapter, true, newAIS);
PlanContext planContext = new PlanContext(compiler);
BasePlannable insertResult = compiler.compile((DMLStatementNode) insertStmt, null, planContext);