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