Examples of NestLoopPlanNode


Examples of org.voltdb.plannodes.NestLoopPlanNode

            nlijNode.addAndLinkChild(subPlan);

            retval = nlijNode;
        }
        else {
            NestLoopPlanNode nljNode = new NestLoopPlanNode(m_context, PlanAssembler.getNextPlanNodeId());
            if ((joinClauses != null) && (joinClauses.size() > 0))
                nljNode.setPredicate(ExpressionUtil.combine(joinClauses));
            nljNode.setJoinType(JoinType.LEFT);

            // combine the tails plan graph with the new head node
            nljNode.addAndLinkChild(nljAccessPlan);

            nljNode.addAndLinkChild(subPlan);

            retval = nljNode;
        }

        /*
 
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

    public void testInnerOuterJoin() {
        AbstractPlanNode pn = compile("select * FROM R1 INNER JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R2.C");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);

        pn = compile("select * FROM R1, R2 LEFT JOIN R3 ON R3.C = R2.C WHERE R1.A = R2.A");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
    }
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

    public void testOuterOuterJoin() {
        AbstractPlanNode pn = compile("select * FROM R1 LEFT JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R1.C");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);

        pn = compile("select * FROM R1 LEFT JOIN R2 ON R1.A = R2.A RIGHT JOIN R3 ON R3.C = R1.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(1);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);

        pn = compile("select * FROM R1 RIGHT JOIN R2 ON R1.A = R2.A RIGHT JOIN R3 ON R3.C = R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(1);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);

        pn = compile("select * FROM R1 RIGHT JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R1.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());

        pn = compile("select * FROM R1 RIGHT JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R1.C WHERE R1.A > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
    }
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

    public void testMultiTableJoinExpressions() {
        AbstractPlanNode pn = compile("select * FROM R1, R2 LEFT JOIN R3 ON R3.A = R2.C OR R3.A = R1.A WHERE R1.C = R2.C");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        AbstractExpression p = nlj.getJoinPredicate();
        assertEquals(ExpressionType.CONJUNCTION_OR, p.getExpressionType());
    }
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

    public void testPushDownExprJoin() {
        // R3.A > 0 gets pushed down all the way to the R3 scan node and used as an index
        AbstractPlanNode pn = compile("select * FROM R3, R2 LEFT JOIN R1 ON R1.C = R2.C WHERE R3.C = R2.C AND R3.A > 0");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof IndexScanPlanNode);

        // R3.A > 0 is now outer join expresion and must stay at the LEF join
        pn = compile("select * FROM R3, R2 LEFT JOIN R1 ON R1.C = R2.C  AND R3.A > 0 WHERE R3.C = R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof SeqScanPlanNode);

        pn = compile("select * FROM R3 JOIN R2 ON R3.C = R2.C RIGHT JOIN R1 ON R1.C = R2.C  AND R3.A > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(1);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof SeqScanPlanNode);

        // R3.A > 0 gets pushed down all the way to the R3 scan node and used as an index
        pn = compile("select * FROM R2, R3 LEFT JOIN R1 ON R1.C = R2.C WHERE R3.C = R2.C AND R3.A > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(1);
        assertTrue(n instanceof IndexScanPlanNode);

        // R3.A = R2.C gets pushed down to the R2, R3 join node scan node and used as an index
        pn = compile("select * FROM R2, R3 LEFT JOIN R1 ON R1.C = R2.C WHERE R3.A = R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopIndexPlanNode);
        NestLoopIndexPlanNode nlij = (NestLoopIndexPlanNode) n;
        assertTrue(JoinType.INNER == nlij.getJoinType());
    }
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

        // before the LEFT-to-RIGHT and the WHERE expressions push down

        AbstractPlanNode pn = compile("select * FROM R1, R3 RIGHT JOIN R2 ON R1.A = R2.A WHERE R3.C = R1.C");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);

        // The second R3.C = R2.C join condition is NULL-rejecting for the first LEFT join
        pn = compile("select * FROM R1 LEFT JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);

        // The second R3.C = R2.C join condition is NULL-rejecting for the first LEFT join
        pn = compile("select * FROM R1 LEFT JOIN R2 ON R1.A = R2.A RIGHT JOIN R3 ON R3.C = R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(1);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
    }
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

        // A.A > 1 Outer Join Expr stays at the the NLJ as pre-join predicate
        // B.A < 0 Inner Join Expr is pushed down to the inner SeqScan node
        AbstractPlanNode pn = compile("select * FROM R1 A LEFT JOIN R1 B ON A.C = B.C AND A.A > 1 AND B.A < 0");
        pn = pn.getChild(0).getChild(0);
        assertTrue(pn instanceof NestLoopPlanNode);
        NestLoopPlanNode nl = (NestLoopPlanNode) pn;
        assertNotNull(nl.getPreJoinPredicate());
        AbstractExpression p = nl.getPreJoinPredicate();
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, p.getExpressionType());
        assertNotNull(nl.getJoinPredicate());
        p = nl.getJoinPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        assertNull(nl.getWherePredicate());
        assertEquals(2, nl.getChildCount());
        SeqScanPlanNode c = (SeqScanPlanNode) nl.getChild(0);
        assertNull(c.getPredicate());
        c = (SeqScanPlanNode) nl.getChild(1);
        assertNotNull(c.getPredicate());
        p = c.getPredicate();
        assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getExpressionType());
    }
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

        assertTrue(n instanceof NestLoopPlanNode);
        p = ((NestLoopPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        n = n.getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertEquals(ExpressionType.COMPARE_EQUAL, nlj.getJoinPredicate().getExpressionType());
        n = n.getChild(0);
        assertTrue(n instanceof AbstractScanPlanNode);
        assertTrue(((AbstractScanPlanNode) n).getTargetTableName().equalsIgnoreCase("R1"));
        p = ((AbstractScanPlanNode) n).getPredicate();
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, p.getExpressionType());
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

        }

        List<AbstractPlanNode> apl;
        AbstractPlanNode node;
        SeqScanPlanNode seqScan;
        NestLoopPlanNode nlj;

        apl = compileToFragments("select * FROM P1 LABEL JOIN R2 USING(A) WHERE A > 0 and R2.C >= 5");
        pn = apl.get(1);
        node = pn.getChild(0);
        assertTrue(node instanceof NestLoopPlanNode);
        assertEquals(ExpressionType.COMPARE_EQUAL,
                     ((NestLoopPlanNode)node).getJoinPredicate().getExpressionType());
        assertTrue(node.getChild(0) instanceof SeqScanPlanNode);
        seqScan = (SeqScanPlanNode)node.getChild(0);
        assertTrue(seqScan.getPredicate() == null);
        node = node.getChild(1);
        assertTrue(node instanceof SeqScanPlanNode);
        seqScan = (SeqScanPlanNode)node;
        assertEquals(ExpressionType.CONJUNCTION_AND, seqScan.getPredicate().getExpressionType());

        apl = compileToFragments("select * FROM P1 LABEL LEFT JOIN R2 USING(A) WHERE A > 0");
        pn = apl.get(1);
        node = pn.getChild(0);
        assertTrue(node instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) node;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertEquals(ExpressionType.COMPARE_EQUAL, nlj.getJoinPredicate().getExpressionType());
        seqScan = (SeqScanPlanNode)node.getChild(0);
        assertTrue(seqScan.getPredicate() != null);
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, seqScan.getPredicate().getExpressionType());

        apl = compileToFragments("select A FROM R2 LABEL RIGHT JOIN P1 AP1 USING(A) WHERE A > 0");
        pn = apl.get(0);
        ns = pn.getOutputSchema();
        assertEquals(1, ns.size());
        SchemaColumn sc = ns.getColumns().get(0);
        assertEquals("AP1", sc.getTableAlias());
        assertEquals("P1", sc.getTableName());
        pn = apl.get(1);
        node = pn.getChild(0);
        assertTrue(node instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) node;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertEquals(ExpressionType.COMPARE_EQUAL, nlj.getJoinPredicate().getExpressionType());
        seqScan = (SeqScanPlanNode)node.getChild(0);
        assertTrue(seqScan.getPredicate() != null);
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, seqScan.getPredicate().getExpressionType());
        ns = seqScan.getOutputSchema();
        assertEquals(1, ns.size());
View Full Code Here

Examples of org.voltdb.plannodes.NestLoopPlanNode

    public void testMultiColumnJoin() {
        // Test multi column condition on non index columns
        AbstractPlanNode pn = compile("select A, C FROM R2 JOIN R1 USING(A, C)");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        AbstractExpression pred = nlj.getJoinPredicate();
        assertNotNull(pred);
        assertEquals(ExpressionType.CONJUNCTION_AND, pred.getExpressionType());

        pn = compile("select R1.A, R2.A FROM R2 JOIN R1 on R1.A = R2.A and R1.C = R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        nlj = (NestLoopPlanNode) n;
        pred = nlj.getJoinPredicate();
        assertNotNull(pred);
        assertEquals(ExpressionType.CONJUNCTION_AND, pred.getExpressionType());

       // Test multi column condition on index columns
        pn = compile("select A FROM R2 JOIN R3 USING(A)");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.