Search in sources :

Example 26 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestPlansCount method testCountStar19.

// Planner bug with Constant value overflow
public void testCountStar19() {
    List<AbstractPlanNode> pn = compileToFragments("SELECT count(*) from T2 WHERE USERNAME ='XIN' AND POINTS >= 3 AND POINTS <= 600000000000000000000000000");
    AbstractPlanNode p = pn.get(0).getChild(0);
    assertTrue((p instanceof IndexCountPlanNode) == false);
    pn = compileToFragments("SELECT count(1) from T2 WHERE USERNAME ='XIN' AND POINTS >= 3 AND POINTS <= 600000000000000000000000000");
    p = pn.get(0).getChild(0);
    assertTrue((p instanceof IndexCountPlanNode) == false);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexCountPlanNode(org.voltdb.plannodes.IndexCountPlanNode)

Example 27 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestJoinOrder method testAliasJoinOrder.

public void testAliasJoinOrder() {
    List<AbstractPlanNode> pns;
    AbstractPlanNode n;
    pns = compileWithJoinOrderToFragments("select * from P1 X, P2 Y where A=B", "X,Y");
    n = pns.get(1).getChild(0);
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(0)).getTargetTableName());
    assertEquals("P2", ((SeqScanPlanNode) n.getChild(1)).getTargetTableName());
    pns = compileWithJoinOrderToFragments("select * from P1, P2 Y where A=B", "P1,Y");
    n = pns.get(1).getChild(0);
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(0)).getTargetTableName());
    assertEquals("P2", ((SeqScanPlanNode) n.getChild(1)).getTargetTableName());
    pns = compileWithJoinOrderToFragments("select * from P1 , P1 Y where P1.A=Y.A", "P1,Y");
    n = pns.get(1).getChild(0);
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(0)).getTargetTableName());
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(1)).getTargetTableName());
    // Test case insensitivity in table and alias names
    pns = compileWithJoinOrderToFragments("select * from P1 x, P2 Y where A=B", "X,y");
    n = pns.get(1).getChild(0);
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(0)).getTargetTableName());
    assertEquals("P2", ((SeqScanPlanNode) n.getChild(1)).getTargetTableName());
    pns = compileWithJoinOrderToFragments("select * from P1 x, P2 Y where A=B", "y,X");
    n = pns.get(1).getChild(0);
    assertEquals("P2", ((SeqScanPlanNode) n.getChild(0)).getTargetTableName());
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(1)).getTargetTableName());
    pns = compileWithJoinOrderToFragments("select * from P1 , P1 YY where P1.A=YY.A", "P1,yY");
    n = pns.get(1).getChild(0);
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(0)).getTargetTableName());
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(1)).getTargetTableName());
    pns = compileWithJoinOrderToFragments("select * from P1 , P1 Yy where P1.A=Yy.A", "p1,YY");
    n = pns.get(1).getChild(0);
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(0)).getTargetTableName());
    assertEquals("P1", ((SeqScanPlanNode) n.getChild(1)).getTargetTableName());
    try {
        // Wants alias "Y", not bogus "Z"
        compileWithInvalidJoinOrder("select * from P1 x, P2 Y where A=B", "x,Z");
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().indexOf(" doesn't exist ") != -1);
    }
    try {
        // Wants alias "Y", not raw table name
        // -- in the future, this may get a specialized message -- or may just be allowed
        compileWithInvalidJoinOrder("select * from P1 x, P2 Y where A=B", "x,P2");
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().indexOf(" doesn't exist ") != -1);
    }
    try {
        // Wants alias "Y", not raw table name (which is arguably ambiguous in this case).
        // -- in the future, this may get a specialized message -- or may just be allowed
        compileWithInvalidJoinOrder("select * from P1 x, P1 Y where x.A=Y.A", "x,P1");
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().indexOf(" doesn't exist ") != -1);
    }
    try {
        // Wants aliases "x,Y", not raw table names (which are definitely ambiguous in this case).
        // -- in the future, this may get a specialized message -- or may just be allowed
        compileWithInvalidJoinOrder("select * from P1 x, P1 Y where x.A=Y.A", "P1,P1");
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().indexOf(" contains a duplicate element ") != -1);
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode)

Example 28 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestMultipleOuterJoinPlans method testOuterOuterJoin.

public void testOuterOuterJoin() {
    AbstractPlanNode pn;
    AbstractPlanNode n;
    pn = compile("select * FROM R1 LEFT JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R1.C");
    n = pn.getChild(0).getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN, null, "R3");
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.SEQSCAN, "R1", "R2");
    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);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.NESTLOOP, "R3", null);
    n = n.getChild(1);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.SEQSCAN, "R1", "R2");
    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);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.NESTLOOP, "R3", null);
    n = n.getChild(1);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.SEQSCAN, "R2", "R1");
    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);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN, null, "R3");
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.SEQSCAN, "R2", "R1");
    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);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN, null, "R3");
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.INNER, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.SEQSCAN);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode)

Example 29 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestMultipleOuterJoinPlans method testInnerOuterJoin.

public void testInnerOuterJoin() {
    AbstractPlanNode pn;
    AbstractPlanNode n;
    pn = compile("select * FROM R1 INNER JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R2.C");
    n = pn.getChild(0).getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN, null, "R3");
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.INNER, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.SEQSCAN);
    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);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN, null, "R3");
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.INNER, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.SEQSCAN);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode)

Example 30 with AbstractPlanNode

use of org.voltdb.plannodes.AbstractPlanNode in project voltdb by VoltDB.

the class TestJoinOrder method testMicroOptimizationJoinOrder.

public void testMicroOptimizationJoinOrder() {
    // Microoptimization can be used for determinism only when working with replicated tables or
    // single-partition queries.
    List<AbstractPlanNode> pns;
    AbstractPlanNode n;
    pns = compileWithJoinOrderToFragments("select * from J1, P2 where A=B and A=1", "J1, P2");
    n = pns.get(0).getChild(0).getChild(0);
    assertTrue(((IndexScanPlanNode) n.getChild(0)).getTargetTableName().equals("J1"));
    assertTrue(((SeqScanPlanNode) n.getChild(1)).getTargetTableName().equals("P2"));
    pns = compileWithJoinOrderToFragments("select * from I1, T2 where A=B", "I1, T2");
    //* enable to debug */ System.out.println(pns.get(0).toExplainPlanString());
    n = pns.get(0).getChild(0).getChild(0);
    assertTrue(((IndexScanPlanNode) n.getChild(0)).getTargetTableName().equals("I1"));
    assertTrue(((SeqScanPlanNode) n.getChild(1)).getTargetTableName().equals("T2"));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Aggregations

AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)259 AbstractExpression (org.voltdb.expressions.AbstractExpression)55 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)48 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)48 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)46 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)44 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)37 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)37 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)29 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)29 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)27 SendPlanNode (org.voltdb.plannodes.SendPlanNode)27 MergeReceivePlanNode (org.voltdb.plannodes.MergeReceivePlanNode)20 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)16 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)16 SchemaColumn (org.voltdb.plannodes.SchemaColumn)15 NodeSchema (org.voltdb.plannodes.NodeSchema)14 UnionPlanNode (org.voltdb.plannodes.UnionPlanNode)14 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)12 PlanNodeType (org.voltdb.types.PlanNodeType)12