Search in sources :

Example 21 with NodeSchema

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

the class TestPlansScalarSubQueries method testSelectCorrelatedScalarInGroupbyClause.

public void testSelectCorrelatedScalarInGroupbyClause() {
    String sql = "select franchise_id, count(*) as stores_in_category_AdHoc " + " from stores group by franchise_id, (select category from store_types where type_id = stores.type_id);";
    AbstractPlanNode pn = compile(sql);
    pn = pn.getChild(0);
    assertTrue(pn instanceof ProjectionPlanNode);
    NodeSchema schema = pn.getOutputSchema();
    assertEquals(2, schema.size());
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    assertNotNull(pn.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
    HashAggregatePlanNode aggNode = (HashAggregatePlanNode) pn.getInlinePlanNode(PlanNodeType.HASHAGGREGATE);
    assertEquals(2, aggNode.getGroupByExpressionsSize());
    AbstractExpression tveExpr = aggNode.getGroupByExpressions().get(0);
    assertTrue(tveExpr instanceof TupleValueExpression);
    AbstractExpression gbExpr = aggNode.getGroupByExpressions().get(1);
    assertTrue(gbExpr instanceof ScalarValueExpression);
    assertTrue(gbExpr.getLeft() instanceof SelectSubqueryExpression);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression) ScalarValueExpression(org.voltdb.expressions.ScalarValueExpression) HashAggregatePlanNode(org.voltdb.plannodes.HashAggregatePlanNode) SelectSubqueryExpression(org.voltdb.expressions.SelectSubqueryExpression) NodeSchema(org.voltdb.plannodes.NodeSchema) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Aggregations

NodeSchema (org.voltdb.plannodes.NodeSchema)21 SchemaColumn (org.voltdb.plannodes.SchemaColumn)15 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)14 AbstractExpression (org.voltdb.expressions.AbstractExpression)13 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)9 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)8 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)8 Table (org.voltdb.catalog.Table)4 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)4 HashMap (java.util.HashMap)3 Column (org.voltdb.catalog.Column)3 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)3 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)3 SendPlanNode (org.voltdb.plannodes.SendPlanNode)3 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)3 Constraint (org.voltdb.catalog.Constraint)2 AbstractSubqueryExpression (org.voltdb.expressions.AbstractSubqueryExpression)2 ScalarValueExpression (org.voltdb.expressions.ScalarValueExpression)2 TupleAddressExpression (org.voltdb.expressions.TupleAddressExpression)2 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)2