use of org.apache.druid.sql.calcite.schema.DruidSchema in project druid by druid-io.
the class CalciteTests method createMockRootSchema.
public static DruidSchemaCatalog createMockRootSchema(final QueryRunnerFactoryConglomerate conglomerate, final SpecificSegmentsQuerySegmentWalker walker, final PlannerConfig plannerConfig, @Nullable final ViewManager viewManager, final DruidSchemaManager druidSchemaManager, final AuthorizerMapper authorizerMapper) {
DruidSchema druidSchema = createMockSchema(conglomerate, walker, plannerConfig, druidSchemaManager);
SystemSchema systemSchema = CalciteTests.createMockSystemSchema(druidSchema, walker, plannerConfig, authorizerMapper);
LookupSchema lookupSchema = CalciteTests.createMockLookupSchema();
ViewSchema viewSchema = viewManager != null ? new ViewSchema(viewManager) : null;
SchemaPlus rootSchema = CalciteSchema.createRootSchema(false, false).plus();
Set<NamedSchema> namedSchemas = new HashSet<>();
namedSchemas.add(new NamedDruidSchema(druidSchema, CalciteTests.DRUID_SCHEMA_NAME));
namedSchemas.add(new NamedSystemSchema(plannerConfig, systemSchema));
namedSchemas.add(new NamedLookupSchema(lookupSchema));
if (viewSchema != null) {
namedSchemas.add(new NamedViewSchema(viewSchema));
}
DruidSchemaCatalog catalog = new DruidSchemaCatalog(rootSchema, namedSchemas.stream().collect(Collectors.toMap(NamedSchema::getSchemaName, x -> x)));
InformationSchema informationSchema = new InformationSchema(catalog, authorizerMapper);
rootSchema.add(CalciteTests.DRUID_SCHEMA_NAME, druidSchema);
rootSchema.add(CalciteTests.INFORMATION_SCHEMA_NAME, informationSchema);
rootSchema.add(NamedSystemSchema.NAME, systemSchema);
rootSchema.add(NamedLookupSchema.NAME, lookupSchema);
if (viewSchema != null) {
rootSchema.add(NamedViewSchema.NAME, viewSchema);
}
return catalog;
}
use of org.apache.druid.sql.calcite.schema.DruidSchema in project druid by druid-io.
the class CalciteTests method createMockSchema.
private static DruidSchema createMockSchema(final QueryRunnerFactoryConglomerate conglomerate, final SpecificSegmentsQuerySegmentWalker walker, final PlannerConfig plannerConfig, final DruidSchemaManager druidSchemaManager) {
final DruidSchema schema = new DruidSchema(CalciteTests.createMockQueryLifecycleFactory(walker, conglomerate), new TestServerInventoryView(walker.getSegments()), new SegmentManager(EasyMock.createMock(SegmentLoader.class)) {
@Override
public Set<String> getDataSourceNames() {
return ImmutableSet.of(BROADCAST_DATASOURCE);
}
}, createDefaultJoinableFactory(), plannerConfig, TEST_AUTHENTICATOR_ESCALATOR, new BrokerInternalQueryConfig(), druidSchemaManager);
try {
schema.start();
schema.awaitInitialization();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
schema.stop();
return schema;
}
Aggregations