context.setGenWholePlan(false);
DruidDQLParser dqlParser = new DruidDQLParser(conf);
DruidDDLParser ddlParser = new DruidDDLParser(conf);
DruidDMLParser dmlParser = new DruidDMLParser(conf);
druidParser = new WaspParser(ddlParser, dqlParser, dmlParser);
TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(conf);
reader.clearCache();
context.setTsr(reader);
// create table
table = new FTable[DruidParserTestUtil.SEED.length];
for (int i = 0; i < DruidParserTestUtil.SEED.length; i++) {
String createTable = DruidParserTestUtil.SEED[i];
context.setSql(createTable);
druidParser.generatePlan(context);
Plan plan = context.getPlan();
if (plan instanceof CreateTablePlan) {
CreateTablePlan createPlan = (CreateTablePlan) plan;
table[i] = createPlan.getTable();
TableSchemaCacheReader.getService(conf).createTable(table[i]);
reader.addSchema(table[i].getTableName(), table[i]);
}
}
for (int i = 0; i < DruidParserTestUtil.INDEX_SEED.length; i++) {
String createIndex = DruidParserTestUtil.INDEX_SEED[i];
context.setSql(createIndex);
druidParser.generatePlan(context);
Plan plan = context.getPlan();
if (plan instanceof CreateIndexPlan) {
CreateIndexPlan createIndexPlan = (CreateIndexPlan) plan;
Index index = createIndexPlan.getIndex();
TableSchemaCacheReader.getService(conf).addIndex(
index.getDependentTableName(), index);
reader.refreshSchema(index.getDependentTableName());
}
}
for (FTable ftable : table) {
TableSchemaCacheReader.getInstance(conf).refreshSchema(
ftable.getTableName());