Package org.apache.drill.exec.planner.physical

Examples of org.apache.drill.exec.planner.physical.Prel


     */
    rel = rel.accept(new RewriteProjectRel(planner.getTypeFactory(), context.getDrillOperatorTable()));
    log("Optiq Logical", rel);
    DrillRel drel = convertToDrel(rel);
    log("Drill Logical", drel);
    Prel prel = convertToPrel(drel);
    log("Drill Physical", prel);
    PhysicalOperator pop = convertToPop(prel);
    PhysicalPlan plan = convertToPlan(pop);
    log("Drill Plan", plan);
    return plan;
View Full Code Here


  }

  protected Prel convertToPrel(RelNode drel) throws RelConversionException {
    Preconditions.checkArgument(drel.getConvention() == DrillRel.DRILL_LOGICAL);
    RelTraitSet traits = drel.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(DrillDistributionTrait.SINGLETON);
    Prel phyRelNode = (Prel) planner.transform(DrillSqlWorker.PHYSICAL_MEM_RULES, traits, drel);

    /*  The order of the following transformation is important */

    /*
     * 0.) For select * from join query, we need insert project on top of scan and a top project just
     * under screen operator. The project on top of scan will rename from * to T1*, while the top project
     * will rename T1* to *, before it output the final result. Only the top project will allow
     * duplicate columns, since user could "explicitly" ask for duplicate columns ( select *, col, *).
     * The rest of projects will remove the duplicate column when we generate POP in json format. 
     */
    phyRelNode = StarColumnConverter.insertRenameProject(phyRelNode, phyRelNode.getRowType());
   
    /*
     * 1.)
     * Join might cause naming conflicts from its left and right child.
     * In such case, we have to insert Project to rename the conflicting names.
View Full Code Here

    if(mode == ResultMode.LOGICAL){
      LogicalExplain logicalResult = new LogicalExplain(drel, level, context);
      return DirectPlan.createDirectPlan(context, logicalResult);
    }

    Prel prel = convertToPrel(drel);
    log("Drill Physical", prel);
    PhysicalOperator pop = convertToPop(prel);
    PhysicalPlan plan = convertToPlan(pop);
    log("Drill Plan", plan);
    PhysicalExplain physicalResult = new PhysicalExplain(prel, plan, level, context);
View Full Code Here

      log("Optiq Logical", relQuery);

      // Convert the query to Drill Logical plan and insert a writer operator on top.
      DrillRel drel = convertToDrel(relQuery, drillSchema, newTblName);
      log("Drill Logical", drel);
      Prel prel = convertToPrel(drel);
      log("Drill Physical", prel);
      PhysicalOperator pop = convertToPop(prel);
      PhysicalPlan plan = convertToPlan(pop);
      log("Drill Plan", plan);
View Full Code Here

    renamedForStar[0] = false;
    renamedForStar[1] = false;

    //root should be screen / writer : no need to rename for the root.

    Prel child = ((Prel) root.getInput(0)).accept(INSTANCE, renamedForStar);

    if (renamedForStar[0] && renamedForStar[1]) {
      List<RexNode> exprs = Lists.newArrayList();
      for (int i = 0; i < origRowType.getFieldCount(); i++) {
        RexNode expr = child.getCluster().getRexBuilder().makeInputRef(origRowType.getFieldList().get(i).getType(), i);
        exprs.add(expr);
      }

      RelDataType newRowType = RexUtil.createStructType(child.getCluster().getTypeFactory(), exprs, origRowType.getFieldNames());

      // Insert a top project which allows duplicate columns.
      child = new ProjectAllowDupPrel(child.getCluster(), child.getTraitSet(), child, exprs, newRowType);

      List<RelNode> children = Lists.newArrayList();
      children.add( child);
      return (Prel) root.copy(root.getTraitSet(), children);
View Full Code Here

  @Override
  public Prel visitExchange(ExchangePrel prel, MajorFragmentStat parent) throws RuntimeException {
    parent.add(prel);
    MajorFragmentStat newFrag = new MajorFragmentStat();
    Prel newChild = ((Prel) prel.getChild()).accept(this, newFrag);

    if(newFrag.isSingular() && parent.isSingular()){
      return newChild;
    }else{
      return (Prel) prel.copy(prel.getTraitSet(), Collections.singletonList((RelNode) newChild));
View Full Code Here

    for(Frag f : frags){
      int id = 1;
      Queue<Prel> ops = Lists.newLinkedList();
      ops.add(f.root);
      while(!ops.isEmpty()){
        Prel p = ops.remove();
        boolean isExchange = p instanceof ExchangePrel;

        if(p != f.root){      // we account for exchanges as receviers to guarantee unique identifiers.
          ids.put(p, new OpId(f.majorFragmentId, id++) );
        }


        if(!isExchange || p == f.root){
          List<Prel> children = Lists.reverse(Lists.newArrayList(p.iterator()));
          for(Prel child : children){
            ops.add(child);
          }
        }
      }
View Full Code Here

    return prel.accept(INSTANCE, null);
  }

  @Override
  public Prel visitScreen(ScreenPrel prel, Void value) throws RuntimeException {
    Prel newChild = ((Prel) prel.getChild()).accept(this, value);
    return prel.copy(prel.getTraitSet(), Collections.singletonList( (RelNode) addTrivialOrderedProjectPrel( newChild )));
  }
View Full Code Here

    return new ProjectPrel(prel.getCluster(), prel.getTraitSet(), prel, projections, prel.getRowType());
  }

  @Override
  public Prel visitWriter(WriterPrel prel, Void value) throws RuntimeException {
    Prel newChild = ((Prel) prel.getChild()).accept(this, null);
    return prel.copy(prel.getTraitSet(), Collections.singletonList( (RelNode) addTrivialOrderedProjectPrel( newChild )));
  }
View Full Code Here

  @Override
  public Prel visitPrel(Prel prel, Void value) throws RuntimeException {
    List<RelNode> children = Lists.newArrayList();
    boolean changed = false;
    for(Prel p : prel){
      Prel newP = p.accept(this, null);
      if(newP != p) changed = true;
      children.add(newP);
    }
    if(changed){
      return (Prel) prel.copy(prel.getTraitSet(), children);
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.planner.physical.Prel

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.