Search in sources :

Example 11 with LogicalPlanPersistence

use of org.apache.drill.common.config.LogicalPlanPersistence in project drill by apache.

the class CheckStorageConfig method checkPlanParsing.

@Test
public void checkPlanParsing() throws Exception {
    DrillConfig config = DrillConfig.create();
    ScanResult scan = ClassPathScanner.fromPrescan(config);
    LogicalPlan plan = LogicalPlan.parse(new LogicalPlanPersistence(config, scan), DrillFileUtils.getResourceAsString("/storage_engine_plan.json"));
}
Also used : ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) DrillConfig(org.apache.drill.common.config.DrillConfig) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 12 with LogicalPlanPersistence

use of org.apache.drill.common.config.LogicalPlanPersistence 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)

Example 13 with LogicalPlanPersistence

use of org.apache.drill.common.config.LogicalPlanPersistence in project drill by apache.

the class TestOpSerialization method setUp.

@Before
public void setUp() {
    config = DrillConfig.create();
    reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(config);
    LogicalPlanPersistence logicalPlanPersistence = PhysicalPlanReaderTestFactory.defaultLogicalPlanPersistence(config);
    writer = logicalPlanPersistence.getMapper().writer();
}
Also used : LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) Before(org.junit.Before)

Example 14 with LogicalPlanPersistence

use of org.apache.drill.common.config.LogicalPlanPersistence in project drill by apache.

the class TestParsePhysicalPlan method parseSimplePlan.

@Test
public void parseSimplePlan() throws Exception {
    DrillConfig c = DrillConfig.create();
    ScanResult scanResult = ClassPathScanner.fromPrescan(c);
    LogicalPlanPersistence lpp = new LogicalPlanPersistence(c, scanResult);
    PhysicalPlanReader reader = new PhysicalPlanReader(c, scanResult, lpp, CoordinationProtos.DrillbitEndpoint.getDefaultInstance(), null);
    ObjectReader r = lpp.getMapper().reader(PhysicalPlan.class);
    ObjectWriter writer = lpp.getMapper().writer();
    PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/physical_test1.json"), Charsets.UTF_8).read());
    plan.unparse(writer);
}
Also used : ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) DrillConfig(org.apache.drill.common.config.DrillConfig) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest) PlannerTest(org.apache.drill.categories.PlannerTest)

Example 15 with LogicalPlanPersistence

use of org.apache.drill.common.config.LogicalPlanPersistence in project drill by apache.

the class BasicOptimizerTest method parseSimplePlan.

@Test
public void parseSimplePlan() throws Exception {
    DrillConfig c = DrillConfig.create();
    LogicalPlanPersistence lpp = PhysicalPlanReaderTestFactory.defaultLogicalPlanPersistence(c);
    LogicalPlan plan = LogicalPlan.parse(lpp, DrillFileUtils.getResourceAsString("/scan_screen_logical.json"));
    plan.unparse(lpp);
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest)

Aggregations

LogicalPlanPersistence (org.apache.drill.common.config.LogicalPlanPersistence)16 DrillConfig (org.apache.drill.common.config.DrillConfig)10 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)8 Test (org.junit.Test)8 LogicalPlan (org.apache.drill.common.logical.LogicalPlan)4 ExecTest (org.apache.drill.exec.ExecTest)4 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)4 SystemOptionManager (org.apache.drill.exec.server.options.SystemOptionManager)4 LocalPersistentStoreProvider (org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider)4 MetricRegistry (com.codahale.metrics.MetricRegistry)2 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 SchemaPlus (org.apache.calcite.schema.SchemaPlus)2 HbaseStorageTest (org.apache.drill.categories.HbaseStorageTest)2 PlannerTest (org.apache.drill.categories.PlannerTest)2 SlowTest (org.apache.drill.categories.SlowTest)2 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)2 QueryContext (org.apache.drill.exec.ops.QueryContext)2