Search in sources :

Example 1 with SystemSchema

use of org.apache.druid.sql.calcite.schema.SystemSchema 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;
}
Also used : SystemSchema(org.apache.druid.sql.calcite.schema.SystemSchema) NamedSystemSchema(org.apache.druid.sql.calcite.schema.NamedSystemSchema) NamedViewSchema(org.apache.druid.sql.calcite.schema.NamedViewSchema) DruidSchema(org.apache.druid.sql.calcite.schema.DruidSchema) NamedDruidSchema(org.apache.druid.sql.calcite.schema.NamedDruidSchema) SchemaPlus(org.apache.calcite.schema.SchemaPlus) InformationSchema(org.apache.druid.sql.calcite.schema.InformationSchema) NamedSchema(org.apache.druid.sql.calcite.schema.NamedSchema) NamedDruidSchema(org.apache.druid.sql.calcite.schema.NamedDruidSchema) NamedLookupSchema(org.apache.druid.sql.calcite.schema.NamedLookupSchema) DruidSchemaCatalog(org.apache.druid.sql.calcite.schema.DruidSchemaCatalog) NamedLookupSchema(org.apache.druid.sql.calcite.schema.NamedLookupSchema) LookupSchema(org.apache.druid.sql.calcite.schema.LookupSchema) ViewSchema(org.apache.druid.sql.calcite.schema.ViewSchema) NamedViewSchema(org.apache.druid.sql.calcite.schema.NamedViewSchema) NamedSystemSchema(org.apache.druid.sql.calcite.schema.NamedSystemSchema) HashSet(java.util.HashSet)

Example 2 with SystemSchema

use of org.apache.druid.sql.calcite.schema.SystemSchema in project druid by druid-io.

the class CalciteTests method createMockSystemSchema.

public static SystemSchema createMockSystemSchema(final DruidSchema druidSchema, final SpecificSegmentsQuerySegmentWalker walker, final PlannerConfig plannerConfig, final AuthorizerMapper authorizerMapper) {
    final DruidNode coordinatorNode = new DruidNode("test-coordinator", "dummy", false, 8081, null, true, false);
    FakeDruidNodeDiscoveryProvider provider = new FakeDruidNodeDiscoveryProvider(ImmutableMap.of(NodeRole.COORDINATOR, new FakeDruidNodeDiscovery(ImmutableMap.of(NodeRole.COORDINATOR, coordinatorNode))));
    final DruidNode overlordNode = new DruidNode("test-overlord", "dummy", false, 8090, null, true, false);
    FakeDruidNodeDiscoveryProvider overlordProvider = new FakeDruidNodeDiscoveryProvider(ImmutableMap.of(NodeRole.OVERLORD, new FakeDruidNodeDiscovery(ImmutableMap.of(NodeRole.OVERLORD, coordinatorNode))));
    final DruidLeaderClient druidLeaderClient = new DruidLeaderClient(new FakeHttpClient(), provider, NodeRole.COORDINATOR, "/simple/leader") {

        @Override
        public String findCurrentLeader() {
            return coordinatorNode.getHostAndPortToUse();
        }
    };
    final DruidLeaderClient overlordLeaderClient = new DruidLeaderClient(new FakeHttpClient(), overlordProvider, NodeRole.OVERLORD, "/simple/leader") {

        @Override
        public String findCurrentLeader() {
            return overlordNode.getHostAndPortToUse();
        }
    };
    return new SystemSchema(druidSchema, new MetadataSegmentView(druidLeaderClient, getJsonMapper(), new BrokerSegmentWatcherConfig(), plannerConfig), new TestServerInventoryView(walker.getSegments()), new FakeServerInventoryView(), authorizerMapper, druidLeaderClient, overlordLeaderClient, provider, getJsonMapper());
}
Also used : SystemSchema(org.apache.druid.sql.calcite.schema.SystemSchema) NamedSystemSchema(org.apache.druid.sql.calcite.schema.NamedSystemSchema) DiscoveryDruidNode(org.apache.druid.discovery.DiscoveryDruidNode) DruidNode(org.apache.druid.server.DruidNode) DruidLeaderClient(org.apache.druid.discovery.DruidLeaderClient) BrokerSegmentWatcherConfig(org.apache.druid.client.BrokerSegmentWatcherConfig) MetadataSegmentView(org.apache.druid.sql.calcite.schema.MetadataSegmentView)

Aggregations

NamedSystemSchema (org.apache.druid.sql.calcite.schema.NamedSystemSchema)2 SystemSchema (org.apache.druid.sql.calcite.schema.SystemSchema)2 HashSet (java.util.HashSet)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1 BrokerSegmentWatcherConfig (org.apache.druid.client.BrokerSegmentWatcherConfig)1 DiscoveryDruidNode (org.apache.druid.discovery.DiscoveryDruidNode)1 DruidLeaderClient (org.apache.druid.discovery.DruidLeaderClient)1 DruidNode (org.apache.druid.server.DruidNode)1 DruidSchema (org.apache.druid.sql.calcite.schema.DruidSchema)1 DruidSchemaCatalog (org.apache.druid.sql.calcite.schema.DruidSchemaCatalog)1 InformationSchema (org.apache.druid.sql.calcite.schema.InformationSchema)1 LookupSchema (org.apache.druid.sql.calcite.schema.LookupSchema)1 MetadataSegmentView (org.apache.druid.sql.calcite.schema.MetadataSegmentView)1 NamedDruidSchema (org.apache.druid.sql.calcite.schema.NamedDruidSchema)1 NamedLookupSchema (org.apache.druid.sql.calcite.schema.NamedLookupSchema)1 NamedSchema (org.apache.druid.sql.calcite.schema.NamedSchema)1 NamedViewSchema (org.apache.druid.sql.calcite.schema.NamedViewSchema)1 ViewSchema (org.apache.druid.sql.calcite.schema.ViewSchema)1