Search in sources :

Example 16 with StoragePluginRegistryImpl

use of org.apache.drill.exec.store.StoragePluginRegistryImpl in project drill by axbaretto.

the class PlanningBase method testSqlPlan.

protected void testSqlPlan(String sqlCommands) throws Exception {
    final DrillbitContext dbContext = mock(DrillbitContext.class);
    final QueryContext context = mock(QueryContext.class);
    final String[] sqlStrings = sqlCommands.split(";");
    final LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
    provider.start();
    final ScanResult scanResult = ClassPathScanner.fromPrescan(config);
    final LogicalPlanPersistence logicalPlanPersistence = new LogicalPlanPersistence(config, scanResult);
    final SystemOptionManager systemOptions = new SystemOptionManager(logicalPlanPersistence, provider, config);
    systemOptions.init();
    @SuppressWarnings("resource") final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
    final SessionOptionManager sessionOptions = userSession.getOptions();
    final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions);
    final ExecutionControls executionControls = new ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
    when(dbContext.getMetrics()).thenReturn(new MetricRegistry());
    when(dbContext.getAllocator()).thenReturn(allocator);
    when(dbContext.getConfig()).thenReturn(config);
    when(dbContext.getOptionManager()).thenReturn(systemOptions);
    when(dbContext.getStoreProvider()).thenReturn(provider);
    when(dbContext.getClasspathScan()).thenReturn(scanResult);
    when(dbContext.getLpPersistence()).thenReturn(logicalPlanPersistence);
    final StoragePluginRegistry registry = new StoragePluginRegistryImpl(dbContext);
    registry.init();
    final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
    final DrillOperatorTable table = new DrillOperatorTable(functionRegistry, systemOptions);
    final SchemaPlus root = CalciteSchema.createRootSchema(false, false).plus();
    registry.getSchemaFactory().registerSchemas(SchemaConfig.newBuilder("foo", context).build(), root);
    when(context.getNewDefaultSchema()).thenReturn(root);
    when(context.getLpPersistence()).thenReturn(new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config)));
    when(context.getStorage()).thenReturn(registry);
    when(context.getFunctionRegistry()).thenReturn(functionRegistry);
    when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().withOptionManager(sessionOptions).setSupportComplexTypes(true).build());
    when(context.getCurrentEndpoint()).thenReturn(DrillbitEndpoint.getDefaultInstance());
    when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(DrillbitEndpoint.getDefaultInstance()));
    when(context.getPlannerSettings()).thenReturn(new PlannerSettings(queryOptions, functionRegistry));
    when(context.getOptions()).thenReturn(queryOptions);
    when(context.getConfig()).thenReturn(config);
    when(context.getDrillOperatorTable()).thenReturn(table);
    when(context.getAllocator()).thenReturn(allocator);
    when(context.getExecutionControls()).thenReturn(executionControls);
    when(context.getLpPersistence()).thenReturn(logicalPlanPersistence);
    for (final String sql : sqlStrings) {
        if (sql.trim().isEmpty()) {
            continue;
        }
        @SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
    }
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) SessionOptionManager(org.apache.drill.exec.server.options.SessionOptionManager) StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) PlannerSettings(org.apache.drill.exec.planner.physical.PlannerSettings) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) QueryOptionManager(org.apache.drill.exec.server.options.QueryOptionManager) MetricRegistry(com.codahale.metrics.MetricRegistry) SchemaPlus(org.apache.calcite.schema.SchemaPlus) QueryContext(org.apache.drill.exec.ops.QueryContext) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) ExecutionControls(org.apache.drill.exec.testing.ExecutionControls) UserSession(org.apache.drill.exec.rpc.user.UserSession) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) DrillOperatorTable(org.apache.drill.exec.planner.sql.DrillOperatorTable)

Example 17 with StoragePluginRegistryImpl

use of org.apache.drill.exec.store.StoragePluginRegistryImpl in project drill by apache.

the class ClusterFixture method defineStoragePlugin.

public void defineStoragePlugin(String name, StoragePluginConfig config) {
    try {
        for (Drillbit drillbit : drillbits()) {
            StoragePluginRegistryImpl registry = (StoragePluginRegistryImpl) drillbit.getContext().getStorage();
            registry.put(name, config);
        }
    } catch (PluginException e) {
        throw new IllegalStateException("Plugin definition failed", e);
    }
}
Also used : Drillbit(org.apache.drill.exec.server.Drillbit) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl) PluginException(org.apache.drill.exec.store.StoragePluginRegistry.PluginException)

Example 18 with StoragePluginRegistryImpl

use of org.apache.drill.exec.store.StoragePluginRegistryImpl in project drill by apache.

the class PlanningBase method testSqlPlan.

protected void testSqlPlan(String sqlCommands) throws Exception {
    final DrillbitContext dbContext = mock(DrillbitContext.class);
    final QueryContext context = mock(QueryContext.class);
    final String[] sqlStrings = sqlCommands.split(";");
    final LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
    provider.start();
    final ScanResult scanResult = ClassPathScanner.fromPrescan(config);
    final LogicalPlanPersistence logicalPlanPersistence = new LogicalPlanPersistence(config, scanResult);
    final SystemOptionManager systemOptions = new SystemOptionManager(logicalPlanPersistence, provider, config);
    systemOptions.init();
    final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
    final SessionOptionManager sessionOptions = userSession.getOptions();
    final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions);
    final ExecutionControls executionControls = new ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
    when(dbContext.getMetrics()).thenReturn(new MetricRegistry());
    when(dbContext.getAllocator()).thenReturn(allocator);
    when(dbContext.getConfig()).thenReturn(config);
    when(dbContext.getOptionManager()).thenReturn(systemOptions);
    when(dbContext.getStoreProvider()).thenReturn(provider);
    when(dbContext.getClasspathScan()).thenReturn(scanResult);
    when(dbContext.getLpPersistence()).thenReturn(logicalPlanPersistence);
    final StoragePluginRegistry registry = new StoragePluginRegistryImpl(dbContext);
    registry.init();
    final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
    final DrillOperatorTable table = new DrillOperatorTable(functionRegistry, systemOptions);
    SchemaConfig schemaConfig = SchemaConfig.newBuilder("foo", context).build();
    SchemaPlus root = DynamicSchema.createRootSchema(registry, schemaConfig, new AliasRegistryProvider(dbContext));
    when(context.getNewDefaultSchema()).thenReturn(root);
    when(context.getLpPersistence()).thenReturn(new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config)));
    when(context.getStorage()).thenReturn(registry);
    when(context.getFunctionRegistry()).thenReturn(functionRegistry);
    when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().withOptionManager(sessionOptions).setSupportComplexTypes(true).build());
    when(context.getCurrentEndpoint()).thenReturn(DrillbitEndpoint.getDefaultInstance());
    when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(DrillbitEndpoint.getDefaultInstance()));
    when(context.getPlannerSettings()).thenReturn(new PlannerSettings(queryOptions, functionRegistry));
    when(context.getOptions()).thenReturn(queryOptions);
    when(context.getConfig()).thenReturn(config);
    when(context.getDrillOperatorTable()).thenReturn(table);
    when(context.getAllocator()).thenReturn(allocator);
    when(context.getExecutionControls()).thenReturn(executionControls);
    when(context.getLpPersistence()).thenReturn(logicalPlanPersistence);
    // mocks for org.apache.drill.TestTpchPlanning#tpch06 test.
    // With changes for decimal types, subtract udf for decimals is used.
    when(context.getManagedBuffer()).thenReturn(allocator.buffer(4));
    when(context.getConstantValueHolder(eq("0.03"), eq(TypeProtos.MinorType.VARDECIMAL), Matchers.<Function<DrillBuf, ValueHolder>>any())).thenReturn(ValueHolderHelper.getVarDecimalHolder(allocator.buffer(4), "0.03"));
    when(context.getConstantValueHolder(eq("0.01"), eq(TypeProtos.MinorType.VARDECIMAL), Matchers.<Function<DrillBuf, ValueHolder>>any())).thenReturn(ValueHolderHelper.getVarDecimalHolder(allocator.buffer(4), "0.01"));
    when(context.getOption(anyString())).thenCallRealMethod();
    for (final String sql : sqlStrings) {
        if (sql.trim().isEmpty()) {
            continue;
        }
        @SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
    }
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) SessionOptionManager(org.apache.drill.exec.server.options.SessionOptionManager) SchemaConfig(org.apache.drill.exec.store.SchemaConfig) PlannerSettings(org.apache.drill.exec.planner.physical.PlannerSettings) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) QueryOptionManager(org.apache.drill.exec.server.options.QueryOptionManager) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) AliasRegistryProvider(org.apache.drill.exec.alias.AliasRegistryProvider) UserSession(org.apache.drill.exec.rpc.user.UserSession) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) DrillOperatorTable(org.apache.drill.exec.planner.sql.DrillOperatorTable) DrillBuf(io.netty.buffer.DrillBuf) StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) MetricRegistry(com.codahale.metrics.MetricRegistry) SchemaPlus(org.apache.calcite.schema.SchemaPlus) QueryContext(org.apache.drill.exec.ops.QueryContext) ValueHolder(org.apache.drill.exec.expr.holders.ValueHolder) ExecutionControls(org.apache.drill.exec.testing.ExecutionControls) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl)

Aggregations

StoragePluginRegistryImpl (org.apache.drill.exec.store.StoragePluginRegistryImpl)18 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)15 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)15 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)13 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)11 Test (org.junit.Test)11 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)10 SimpleRootExec (org.apache.drill.exec.physical.impl.SimpleRootExec)9 ValueVector (org.apache.drill.exec.vector.ValueVector)9 Ignore (org.junit.Ignore)9 FragmentContextImpl (org.apache.drill.exec.ops.FragmentContextImpl)8 StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)8 OperatorTest (org.apache.drill.categories.OperatorTest)6 SlowTest (org.apache.drill.categories.SlowTest)6 UserClientConnection (org.apache.drill.exec.rpc.UserClientConnection)6 FragmentContext (org.apache.drill.exec.ops.FragmentContext)5 Drillbit (org.apache.drill.exec.server.Drillbit)4 DrillBuf (io.netty.buffer.DrillBuf)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 SchemaPlus (org.apache.calcite.schema.SchemaPlus)2