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);
}
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);
}
}
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);
}
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);
}
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"));
}
Aggregations