Search in sources :

Example 16 with AbstractScanPlanNode

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

the class TestPlansScalarSubQueries method testSelectCorrelatedScalar.

public void testSelectCorrelatedScalar() {
    AbstractPlanNode pn = compile("select r2.c, (select d from r1 where r1.c = r2.c ) scalar from r2");
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    AbstractPlanNode proj = pn.getInlinePlanNode(PlanNodeType.PROJECTION);
    NodeSchema schema = proj.getOutputSchema();
    assertEquals(2, schema.size());
    SchemaColumn col = schema.getColumns().get(1);
    assertTrue(col != null);
    assertEquals("SCALAR", col.getColumnName());
    AbstractExpression colExpr = col.getExpression();
    assertEquals(ExpressionType.VALUE_SCALAR, colExpr.getExpressionType());
    assertTrue(colExpr.getLeft() instanceof AbstractSubqueryExpression);
    AbstractSubqueryExpression subqueryExpr = (AbstractSubqueryExpression) colExpr.getLeft();
    List<Integer> params = subqueryExpr.getParameterIdxList();
    assertEquals(1, params.size());
    assertEquals(new Integer(0), params.get(0));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression) AbstractSubqueryExpression(org.voltdb.expressions.AbstractSubqueryExpression) SchemaColumn(org.voltdb.plannodes.SchemaColumn) NodeSchema(org.voltdb.plannodes.NodeSchema)

Example 17 with AbstractScanPlanNode

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

the class TestPlansScalarSubQueries method testWhereUserParamScalar.

public void testWhereUserParamScalar() {
    AbstractPlanNode pn = compile("select r2.c from r2 where r2.c = (select r1.a from r1 where r1.a = ?);");
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    AbstractExpression pred = ((AbstractScanPlanNode) pn).getPredicate();
    assertEquals(ExpressionType.COMPARE_EQUAL, pred.getExpressionType());
    assertEquals(ExpressionType.VALUE_TUPLE, pred.getLeft().getExpressionType());
    assertEquals(ExpressionType.SELECT_SUBQUERY, pred.getRight().getExpressionType());
    assertEquals(0, pred.getRight().getArgs().size());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 18 with AbstractScanPlanNode

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

the class TestPlansScalarSubQueries method testSelectScalar.

public void testSelectScalar() {
    AbstractPlanNode pn = compile("select r2.c, (select d from r1) scalar from r2");
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    AbstractPlanNode proj = pn.getInlinePlanNode(PlanNodeType.PROJECTION);
    NodeSchema schema = proj.getOutputSchema();
    assertEquals(2, schema.size());
    SchemaColumn col = schema.getColumns().get(1);
    assertTrue(col != null);
    assertEquals("SCALAR", col.getColumnName());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) SchemaColumn(org.voltdb.plannodes.SchemaColumn) NodeSchema(org.voltdb.plannodes.NodeSchema)

Example 19 with AbstractScanPlanNode

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

the class TestPlansJoin method testScanJoinConditions.

public void testScanJoinConditions() {
    String query;
    AbstractPlanNode pn;
    AbstractPlanNode node;
    AbstractScanPlanNode scan;
    AbstractExpression predicate;
    query = "SELECT * FROM R1 WHERE R1.C = 0";
    pn = compileToTopDownTree(query, 3, PlanNodeType.SEND, PlanNodeType.SEQSCAN);
    node = followAssertedLeftChain(pn, PlanNodeType.SEND, PlanNodeType.SEQSCAN);
    scan = (AbstractScanPlanNode) node;
    predicate = scan.getPredicate();
    assertExprTopDownTree(predicate, ExpressionType.COMPARE_EQUAL, ExpressionType.VALUE_TUPLE, ExpressionType.VALUE_CONSTANT);
    for (JoinOp joinOp : JoinOp.JOIN_OPS) {
        perJoinOpTestScanJoinConditions(joinOp);
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 20 with AbstractScanPlanNode

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

the class TestPlansScalarSubQueries method testWhereEqualScalar.

public void testWhereEqualScalar() {
    AbstractPlanNode pn = compile("select r2.c from r2 where (select r1.a from r1) = r2.c;");
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    AbstractExpression pred = ((AbstractScanPlanNode) pn).getPredicate();
    assertEquals(ExpressionType.COMPARE_EQUAL, pred.getExpressionType());
    assertEquals(ExpressionType.VALUE_TUPLE, pred.getLeft().getExpressionType());
    assertEquals(ExpressionType.SELECT_SUBQUERY, pred.getRight().getExpressionType());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Aggregations

AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)48 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)46 AbstractExpression (org.voltdb.expressions.AbstractExpression)21 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)15 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)14 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)14 NodeSchema (org.voltdb.plannodes.NodeSchema)8 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)8 AbstractSubqueryExpression (org.voltdb.expressions.AbstractSubqueryExpression)7 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)7 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)6 SchemaColumn (org.voltdb.plannodes.SchemaColumn)6 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)5 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)4 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)4 ArrayList (java.util.ArrayList)3 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)3 AbstractJoinPlanNode (org.voltdb.plannodes.AbstractJoinPlanNode)3 PlanNodeType (org.voltdb.types.PlanNodeType)3 JSONException (org.json_voltpatches.JSONException)2