Package org.apache.drill.common.logical

Examples of org.apache.drill.common.logical.LogicalPlan


public class Simple {
  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Simple.class);
 
  public static void main(String[] args) throws Exception {
    DrillConfig c = DrillConfig.create();
    LogicalPlan plan = LogicalPlan.parse(c, FileUtils.getResourceAsString("/jdbc_plan.json"));
    System.out.println(plan.toJsonString(c));
  }
View Full Code Here


    assertEquals(engines.size(), 1);
  }
 
  @Test
  public void checkPlanParsing() throws Exception{
    LogicalPlan plan = LogicalPlan.parse(DrillConfig.create(), FileUtils.getResourceAsString("/storage_engine_plan.json"));
  }
View Full Code Here

  }

  private void parseAndRunLogicalPlan(String json) {
   
    try {
      LogicalPlan logicalPlan = context.getPlanReader().readLogicalPlan(json);
      if(logger.isDebugEnabled()) logger.debug("Logical {}", logicalPlan.unparse(context.getConfig()));
      PhysicalPlan physicalPlan = convert(logicalPlan);
      if(logger.isDebugEnabled()) logger.debug("Physical {}", context.getConfig().getMapper().writeValueAsString(physicalPlan));
      runPhysicalPlan(physicalPlan);
    } catch (IOException e) {
      fail("Failure while parsing logical plan.", e);
View Full Code Here

 
 
  @Test
  public void parseSimplePlan() throws Throwable{
    DrillConfig config = DrillConfig.create();
    LogicalPlan plan = LogicalPlan.parse(config, Files.toString(FileUtils.getResourceAsFile("/simple_plan.json"), Charsets.UTF_8));
    IteratorRegistry ir = new IteratorRegistry();
    ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new BasicEvaluatorFactory(ir), new RSERegistry(config));
    i.setup();
    Collection<RunOutcome> outcomes = i.run();
    assertEquals(outcomes.size(), 1);
View Full Code Here

  }
 
  @Test
  public void joinPlan() throws Throwable{
    DrillConfig config = DrillConfig.create();
    LogicalPlan plan = LogicalPlan.parse(config, Files.toString(FileUtils.getResourceAsFile("/simple_join.json"), Charsets.UTF_8));
    IteratorRegistry ir = new IteratorRegistry();
    ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new BasicEvaluatorFactory(ir), new RSERegistry(config));
    i.setup();
    Collection<RunOutcome> outcomes = i.run();
    assertEquals(outcomes.size(), 1);
View Full Code Here

  }
 
  @Test
  public void flattenPlan() throws Throwable{
    DrillConfig config = DrillConfig.create();
    LogicalPlan plan = LogicalPlan.parse(config, Files.toString(FileUtils.getResourceAsFile("/simple_plan_flattened.json"), Charsets.UTF_8));
    IteratorRegistry ir = new IteratorRegistry();
    ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new BasicEvaluatorFactory(ir), new RSERegistry(config));
    i.setup();
    Collection<RunOutcome> outcomes = i.run();
    assertEquals(outcomes.size(), 1);
View Full Code Here

    @Test
    @Ignore // this plan needs to be updated.
    public void testRefInterp() throws Exception{
            DrillConfig config = DrillConfig.create();
            final String jsonFile = "/constant2.json";
            LogicalPlan plan = LogicalPlan.parse(config, FileUtils.getResourceAsString(jsonFile));
            org.junit.Assert.assertEquals("Constant operator not read in properly or not recognized as a source operator.",
                    plan.getGraph().getLeaves().toString(), "[Constant [memo=null]]");

            org.junit.Assert.assertEquals("Edge between constant operator and sink not recognized.",
                    plan.getGraph().getRoots().toString(), "[Store [memo=output sink]]");

           
            IteratorRegistry ir = new IteratorRegistry();
            ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new BasicEvaluatorFactory(ir), new RSERegistry(config));
            i.setup();
View Full Code Here

   * @param resourcePath Path for JSON logical plan
   * @return A collection of RunOutcomes
   * @throws IOException
   */
  public static Collection<RunOutcome> getOutcome(DrillConfig config, String resourcePath) throws IOException{
    LogicalPlan plan = LogicalPlan.parse(config, Files.toString(FileUtils.getResourceAsFile(resourcePath), Charsets.UTF_8));
    IteratorRegistry ir = new IteratorRegistry();
    ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new BasicEvaluatorFactory(ir), new RSERegistry(config));
    i.setup();
    return i.run();
  }
View Full Code Here

    if (jsonFile.startsWith("inline:")) {
      planString = jsonFile.substring("inline:".length());
    } else {
      planString = Files.toString(new File(jsonFile), Charsets.UTF_8);
    }
    LogicalPlan plan = LogicalPlan.parse(config, planString);
    IteratorRegistry ir = new IteratorRegistry();
    ReferenceInterpreter i = new ReferenceInterpreter(plan, ir, new BasicEvaluatorFactory(ir), new RSERegistry(config));
    i.setup();
    final Object[] result = {null};
    final Thread thread;
View Full Code Here

  /**
   * Creates a DrillEnumerable from a plan represented as a string. Each record returned is a {@link JsonNode}.
   */
  public static <E> EnumerableDrill<E> of(DrillHandler handler, String plan, final List<String> fieldNames, Class<E> clazz) {
    DrillConfig config = DrillConfig.create();
    final LogicalPlan parse = LogicalPlan.parse(config, plan);
    return new EnumerableDrill<>(config, parse, clazz, fieldNames);
  }
View Full Code Here

TOP

Related Classes of org.apache.drill.common.logical.LogicalPlan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.