Search in sources :

Example 36 with SchemaColumn

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

the class TestPlansScalarSubQueries method testSelectParameterScalar.

public void testSelectParameterScalar() {
    AbstractPlanNode pn = compile("select r2.c, (select d from r1 where r1.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();
    AbstractPlanNode subquery = subqueryExpr.getSubqueryNode();
    assertEquals(PlanNodeType.SEQSCAN, subquery.getPlanNodeType());
    AbstractExpression pred = ((SeqScanPlanNode) subquery).getPredicate();
    assertEquals(ExpressionType.VALUE_PARAMETER, pred.getRight().getExpressionType());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) 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 37 with SchemaColumn

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

the class TestPlansScalarSubQueries method testSelectCorrelatedScalarWithGroupby.

public void testSelectCorrelatedScalarWithGroupby() {
    String sql = "select franchise_id, count(*) as stores_in_category_AdHoc, " + " (select category from store_types where type_id = stores.type_id) as store_category " + "from stores group by franchise_id, type_id;";
    AbstractPlanNode pn = compile(sql);
    pn = pn.getChild(0);
    assertTrue(pn instanceof ProjectionPlanNode);
    NodeSchema schema = pn.getOutputSchema();
    assertEquals(3, schema.size());
    SchemaColumn col = schema.getColumns().get(2);
    assertTrue(col != null);
    assertEquals("STORE_CATEGORY", col.getColumnName());
    assertTrue(col.getExpression() instanceof ScalarValueExpression);
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    assertNotNull(pn.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) ScalarValueExpression(org.voltdb.expressions.ScalarValueExpression) SchemaColumn(org.voltdb.plannodes.SchemaColumn) NodeSchema(org.voltdb.plannodes.NodeSchema) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Aggregations

SchemaColumn (org.voltdb.plannodes.SchemaColumn)37 AbstractExpression (org.voltdb.expressions.AbstractExpression)19 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)16 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)13 NodeSchema (org.voltdb.plannodes.NodeSchema)13 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)6 HashSet (java.util.HashSet)5 StmtTableScan (org.voltdb.planner.parseinfo.StmtTableScan)5 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)5 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)5 Table (org.voltdb.catalog.Table)4 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)4 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Column (org.voltdb.catalog.Column)3 Constraint (org.voltdb.catalog.Constraint)3 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)3 SendPlanNode (org.voltdb.plannodes.SendPlanNode)3 Set (java.util.Set)2