Ejemplo n.º 1
0
  @Test
  public final void testFindTopNode() throws CloneNotSupportedException, PlanningException {
    // two relations
    Expr expr = analyzer.parse(TestLogicalPlanner.QUERIES[1]);
    LogicalNode plan = planner.createPlan(expr).getRootBlock().getRoot();

    assertEquals(NodeType.ROOT, plan.getType());
    LogicalRootNode root = (LogicalRootNode) plan;
    TestLogicalNode.testCloneLogicalNode(root);

    assertEquals(NodeType.PROJECTION, root.getChild().getType());
    ProjectionNode projNode = (ProjectionNode) root.getChild();

    assertEquals(NodeType.JOIN, projNode.getChild().getType());
    JoinNode joinNode = (JoinNode) projNode.getChild();

    assertEquals(NodeType.SCAN, joinNode.getLeftChild().getType());
    ScanNode leftNode = (ScanNode) joinNode.getLeftChild();
    assertEquals("employee", leftNode.getTableName());
    assertEquals(NodeType.SCAN, joinNode.getRightChild().getType());
    ScanNode rightNode = (ScanNode) joinNode.getRightChild();
    assertEquals("dept", rightNode.getTableName());

    LogicalNode node = PlannerUtil.findTopNode(root, NodeType.ROOT);
    assertEquals(NodeType.ROOT, node.getType());

    node = PlannerUtil.findTopNode(root, NodeType.PROJECTION);
    assertEquals(NodeType.PROJECTION, node.getType());

    node = PlannerUtil.findTopNode(root, NodeType.JOIN);
    assertEquals(NodeType.JOIN, node.getType());

    node = PlannerUtil.findTopNode(root, NodeType.SCAN);
    assertEquals(NodeType.SCAN, node.getType());
  }
Ejemplo n.º 2
0
    @Override
    public PhysicalExec createScanPlan(
        TaskAttemptContext ctx, ScanNode scanNode, Stack<LogicalNode> stack) throws IOException {
      Preconditions.checkNotNull(
          ctx.getTable(scanNode.getTableName()),
          "Error: There is no table matched to %s",
          scanNode.getTableName());

      List<FileFragment> fragments =
          FragmentConvertor.convert(
              ctx.getConf(), meta.getStoreType(), ctx.getTables(scanNode.getTableName()));

      Datum[] datum = new Datum[] {DatumFactory.createInt4(rndKey)};

      return new BSTIndexScanExec(
          ctx, sm, scanNode, fragments.get(0), idxPath, idxSchema, comp, datum);
    }