Search in sources :

Example 1 with PlanProperties

use of org.apache.drill.common.logical.PlanProperties in project drill by axbaretto.

the class JdbcDataTest method testProjectFilterSubqueryPlan.

@Test
public void testProjectFilterSubqueryPlan() throws Exception {
    LogicalPlan plan = withModel(MODEL, "DONUTS").sql("select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP['donuts'] as d from donuts)\n" + "where cast(d['ppu'] as double) > 0.6").logicalPlan();
    PlanProperties planProperties = plan.getProperties();
    Assert.assertEquals("optiq", planProperties.generator.type);
    Assert.assertEquals("na", planProperties.generator.info);
    Assert.assertEquals(1, planProperties.version);
    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
    StoragePluginConfig config = seConfigs.get("donuts-json");
    // Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
    config = seConfigs.get("queue");
    // Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
    Scan scan = findOnlyOperator(plan, Scan.class);
    Assert.assertEquals("donuts-json", scan.getStorageEngine());
    Filter filter = findOnlyOperator(plan, Filter.class);
    Assert.assertTrue(filter.getInput() instanceof Scan);
    Project[] projects = Iterables.toArray(findOperator(plan, Project.class), Project.class);
    Assert.assertEquals(2, projects.length);
    Assert.assertEquals(1, projects[0].getSelections().size());
    Assert.assertEquals(Filter.class, projects[0].getInput().getClass());
    Assert.assertEquals(2, projects[1].getSelections().size());
    Assert.assertEquals(Project.class, projects[1].getInput().getClass());
    Store store = findOnlyOperator(plan, Store.class);
    Assert.assertEquals("queue", store.getStorageEngine());
    Assert.assertEquals("output sink", store.getMemo());
    Assert.assertEquals(Project.class, store.getInput().getClass());
}
Also used : Project(org.apache.drill.common.logical.data.Project) PlanProperties(org.apache.drill.common.logical.PlanProperties) Filter(org.apache.drill.common.logical.data.Filter) Store(org.apache.drill.common.logical.data.Store) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) Scan(org.apache.drill.common.logical.data.Scan) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 2 with PlanProperties

use of org.apache.drill.common.logical.PlanProperties in project drill by apache.

the class BasicOptimizer method optimize.

@Override
public PhysicalPlan optimize(final OptimizationContext context, final LogicalPlan plan) throws OptimizerException {
    final Object obj = new Object();
    final Collection<SinkOperator> roots = plan.getGraph().getRoots();
    final List<PhysicalOperator> physOps = new ArrayList<>(roots.size());
    final LogicalConverter converter = new LogicalConverter(plan);
    for (SinkOperator op : roots) {
        final PhysicalOperator pop = op.accept(converter, obj);
        physOps.add(pop);
    }
    final PlanProperties logicalProperties = plan.getProperties();
    final PlanProperties props = PlanProperties.builder().type(PlanProperties.PlanType.APACHE_DRILL_PHYSICAL).version(logicalProperties.version).generator(logicalProperties.generator).options(new JSONOptions(context.getOptions().getOptionList())).build();
    return new PhysicalPlan(props, physOps);
}
Also used : JSONOptions(org.apache.drill.common.JSONOptions) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) SinkOperator(org.apache.drill.common.logical.data.SinkOperator) PlanProperties(org.apache.drill.common.logical.PlanProperties) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) ArrayList(java.util.ArrayList)

Example 3 with PlanProperties

use of org.apache.drill.common.logical.PlanProperties in project drill by axbaretto.

the class JdbcDataTest method testProjectPlan.

/**
 * Checks the logical plan.
 */
@Test
public void testProjectPlan() throws Exception {
    LogicalPlan plan = withModel(MODEL, "DONUTS").sql("select _MAP['ppu'] as ppu from donuts").logicalPlan();
    PlanProperties planProperties = plan.getProperties();
    Assert.assertEquals("optiq", planProperties.generator.type);
    Assert.assertEquals("na", planProperties.generator.info);
    Assert.assertEquals(1, planProperties.version);
    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
    StoragePluginConfig config = seConfigs.get("donuts-json");
    // Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
    config = seConfigs.get("queue");
    // Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
    Scan scan = findOnlyOperator(plan, Scan.class);
    Assert.assertEquals("donuts-json", scan.getStorageEngine());
    Project project = findOnlyOperator(plan, Project.class);
    Assert.assertEquals(1, project.getSelections().size());
    Assert.assertEquals(Scan.class, project.getInput().getClass());
    Store store = findOnlyOperator(plan, Store.class);
    Assert.assertEquals("queue", store.getStorageEngine());
    Assert.assertEquals("output sink", store.getMemo());
    Assert.assertEquals(Project.class, store.getInput().getClass());
}
Also used : Project(org.apache.drill.common.logical.data.Project) PlanProperties(org.apache.drill.common.logical.PlanProperties) Store(org.apache.drill.common.logical.data.Store) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) Scan(org.apache.drill.common.logical.data.Scan) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 4 with PlanProperties

use of org.apache.drill.common.logical.PlanProperties in project drill by axbaretto.

the class BasicOptimizer method optimize.

@Override
public PhysicalPlan optimize(final OptimizationContext context, final LogicalPlan plan) throws OptimizerException {
    final Object obj = new Object();
    final Collection<SinkOperator> roots = plan.getGraph().getRoots();
    final List<PhysicalOperator> physOps = new ArrayList<>(roots.size());
    final LogicalConverter converter = new LogicalConverter(plan);
    for (SinkOperator op : roots) {
        final PhysicalOperator pop = op.accept(converter, obj);
        physOps.add(pop);
    }
    final PlanProperties logicalProperties = plan.getProperties();
    final PlanProperties props = PlanProperties.builder().type(PlanProperties.PlanType.APACHE_DRILL_PHYSICAL).version(logicalProperties.version).generator(logicalProperties.generator).options(new JSONOptions(context.getOptions().getOptionList())).build();
    final PhysicalPlan p = new PhysicalPlan(props, physOps);
    return p;
}
Also used : JSONOptions(org.apache.drill.common.JSONOptions) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) SinkOperator(org.apache.drill.common.logical.data.SinkOperator) PlanProperties(org.apache.drill.common.logical.PlanProperties) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) ArrayList(java.util.ArrayList)

Example 5 with PlanProperties

use of org.apache.drill.common.logical.PlanProperties in project drill by apache.

the class JdbcDataTest method testProjectPlan.

/**
 * Checks the logical plan.
 */
@Test
public void testProjectPlan() throws Exception {
    LogicalPlan plan = withModel(MODEL, "DONUTS").sql("select _MAP['ppu'] as ppu from donuts").logicalPlan();
    PlanProperties planProperties = plan.getProperties();
    Assert.assertEquals("optiq", planProperties.generator.type);
    Assert.assertEquals("na", planProperties.generator.info);
    Assert.assertEquals(1, planProperties.version);
    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
    StoragePluginConfig config = seConfigs.get("donuts-json");
    // Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
    config = seConfigs.get("queue");
    // Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
    Scan scan = findOnlyOperator(plan, Scan.class);
    Assert.assertEquals("donuts-json", scan.getStorageEngine());
    Project project = findOnlyOperator(plan, Project.class);
    Assert.assertEquals(1, project.getSelections().size());
    Assert.assertEquals(Scan.class, project.getInput().getClass());
    Store store = findOnlyOperator(plan, Store.class);
    Assert.assertEquals("queue", store.getStorageEngine());
    Assert.assertEquals("output sink", store.getMemo());
    Assert.assertEquals(Project.class, store.getInput().getClass());
}
Also used : Project(org.apache.drill.common.logical.data.Project) PlanProperties(org.apache.drill.common.logical.PlanProperties) Store(org.apache.drill.common.logical.data.Store) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) Scan(org.apache.drill.common.logical.data.Scan) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Aggregations

PlanProperties (org.apache.drill.common.logical.PlanProperties)6 JdbcTest (org.apache.drill.categories.JdbcTest)4 LogicalPlan (org.apache.drill.common.logical.LogicalPlan)4 StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)4 Project (org.apache.drill.common.logical.data.Project)4 Scan (org.apache.drill.common.logical.data.Scan)4 Store (org.apache.drill.common.logical.data.Store)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 JSONOptions (org.apache.drill.common.JSONOptions)2 Filter (org.apache.drill.common.logical.data.Filter)2 SinkOperator (org.apache.drill.common.logical.data.SinkOperator)2 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)2 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)2