use of io.druid.sql.calcite.schema.DruidSchema in project druid by druid-io.
the class CalciteQueryTest method getResults.
private List<Object[]> getResults(final PlannerContext plannerContext, final String sql) throws Exception {
final PlannerConfig plannerConfig = plannerContext.getPlannerConfig();
final DruidSchema druidSchema = CalciteTests.createMockSchema(walker, plannerConfig);
final SchemaPlus rootSchema = Calcites.createRootSchema(druidSchema);
final DruidOperatorTable operatorTable = CalciteTests.createOperatorTable();
final PlannerFactory plannerFactory = new PlannerFactory(rootSchema, walker, operatorTable, plannerConfig);
try (DruidPlanner planner = plannerFactory.createPlanner(plannerContext.getQueryContext())) {
final PlannerResult plan = planner.plan(sql);
return Sequences.toList(plan.run(), Lists.<Object[]>newArrayList());
}
}
use of io.druid.sql.calcite.schema.DruidSchema in project druid by druid-io.
the class CalciteTests method createMockSchema.
public static DruidSchema createMockSchema(final SpecificSegmentsQuerySegmentWalker walker, final PlannerConfig plannerConfig) {
final DruidSchema schema = new DruidSchema(walker, new TestServerInventoryView(walker.getSegments()), plannerConfig);
schema.start();
try {
schema.awaitInitialization();
} catch (InterruptedException e) {
throw Throwables.propagate(e);
}
schema.stop();
return schema;
}
Aggregations