use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class TestPlansScalarSubQueries method testWhereGreaterRow.
public void testWhereGreaterRow() {
AbstractPlanNode pn = compile("select r5.c from r5 where (a,c) > (select r1.a, r1.c from r1);");
pn = pn.getChild(0);
assertTrue(pn instanceof AbstractScanPlanNode);
AbstractExpression pred = ((AbstractScanPlanNode) pn).getPredicate();
assertEquals(ExpressionType.COMPARE_GREATERTHAN, pred.getExpressionType());
assertEquals(ExpressionType.ROW_SUBQUERY, pred.getLeft().getExpressionType());
assertEquals(ExpressionType.SELECT_SUBQUERY, pred.getRight().getExpressionType());
}
use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class TestPushDownAggregates method checkPushedDown.
private void checkPushedDown(List<AbstractPlanNode> pn, boolean isAggInlined, ExpressionType[] aggTypes, ExpressionType[] pushDownTypes, boolean hasProjectionNode) {
// Aggregate push down check has to run on two fragments
assertTrue(pn.size() == 2);
AbstractPlanNode p = pn.get(0).getChild(0);
;
if (hasProjectionNode) {
// Complex aggregation or optimized AVG
assertTrue(p instanceof ProjectionPlanNode);
p = p.getChild(0);
}
assertTrue(p instanceof AggregatePlanNode);
String fragmentString = p.toJSONString();
ExpressionType[] topTypes = (pushDownTypes != null) ? pushDownTypes : aggTypes;
for (ExpressionType type : topTypes) {
assertTrue(fragmentString.contains("\"AGGREGATE_TYPE\":\"" + type.toString() + "\""));
}
// Check the pushed down aggregation
p = pn.get(1).getChild(0);
if (pushDownTypes == null) {
assertTrue(p instanceof AbstractScanPlanNode);
return;
}
if (isAggInlined) {
// See ENG-6131
if (p instanceof TableCountPlanNode) {
return;
}
assertTrue(p instanceof AbstractScanPlanNode);
assertTrue(p.getInlinePlanNode(PlanNodeType.AGGREGATE) != null || p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE) != null);
if (p.getInlinePlanNode(PlanNodeType.AGGREGATE) != null) {
p = p.getInlinePlanNode(PlanNodeType.AGGREGATE);
} else {
p = p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE);
}
} else {
assertTrue(p instanceof AggregatePlanNode);
}
fragmentString = p.toJSONString();
for (ExpressionType type : aggTypes) {
assertTrue(fragmentString.contains("\"AGGREGATE_TYPE\":\"" + type.toString() + "\""));
}
}
use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class TestPushDownAggregates method testAggregatesOnDistinctPKey.
//ENG-4980
public void testAggregatesOnDistinctPKey() {
List<AbstractPlanNode> pn = compileToFragments("SELECT count(distinct PKEY), sum(distinct PKEY), min(distinct PKEY), max(distinct PKEY), avg(distinct PKEY)" + " FROM T1;");
for (AbstractPlanNode apn : pn) {
System.out.println(apn.toExplainPlanString());
}
checkPushedDown(pn, true, new ExpressionType[] { ExpressionType.AGGREGATE_COUNT, ExpressionType.AGGREGATE_SUM, ExpressionType.AGGREGATE_MIN, ExpressionType.AGGREGATE_MAX, ExpressionType.AGGREGATE_SUM, ExpressionType.AGGREGATE_COUNT }, new ExpressionType[] { ExpressionType.AGGREGATE_SUM, ExpressionType.AGGREGATE_SUM, ExpressionType.AGGREGATE_MIN, ExpressionType.AGGREGATE_MAX, ExpressionType.AGGREGATE_SUM, ExpressionType.AGGREGATE_SUM }, true);
// Test count(distinct pkey) with other compatible aggs like non-distinct aggs of other columns.
pn = compileToFragments("SELECT count(distinct PKEY), count(A1), min(distinct PKEY), max(distinct A1), sum(A1)" + " FROM T1;");
for (AbstractPlanNode apn : pn) {
System.out.println(apn.toExplainPlanString());
}
checkPushedDown(pn, true, new ExpressionType[] { ExpressionType.AGGREGATE_COUNT, ExpressionType.AGGREGATE_COUNT, ExpressionType.AGGREGATE_MIN, ExpressionType.AGGREGATE_MAX, ExpressionType.AGGREGATE_SUM }, new ExpressionType[] { ExpressionType.AGGREGATE_SUM, ExpressionType.AGGREGATE_SUM, ExpressionType.AGGREGATE_MIN, ExpressionType.AGGREGATE_MAX, ExpressionType.AGGREGATE_SUM });
// Negative test case: count(distinct pkey) and count(distinct other) to show that
// it only takes one other non-trivial distinct on another column to disable the pushdown.
pn = compileToFragments("SELECT count(distinct PKEY), count(distinct A1) FROM T1;");
assertTrue(pn.size() == 2);
assertTrue(pn.get(1).getChild(0) instanceof AbstractScanPlanNode);
AbstractScanPlanNode asp = (AbstractScanPlanNode) pn.get(1).getChild(0);
assertTrue(asp.getInlinePlanNode(PlanNodeType.AGGREGATE) == null);
}
use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class MaterializedViewFixInfo method processScanNodeWithReAggNode.
/**
* Find the scan node on MV table, replace it with reAggNode for join query.
* This scan node can not be in-lined, so it should be as a child of a join node.
* @param node
*/
public boolean processScanNodeWithReAggNode(AbstractPlanNode node, AbstractPlanNode reAggNode) {
// MV table scan node can not be in in-lined nodes.
for (int i = 0; i < node.getChildCount(); i++) {
AbstractPlanNode child = node.getChild(i);
if (child instanceof AbstractScanPlanNode) {
AbstractScanPlanNode scanNode = (AbstractScanPlanNode) child;
if (!scanNode.getTargetTableName().equals(getMVTableName())) {
continue;
}
if (reAggNode != null) {
// Join query case.
node.setAndLinkChild(i, reAggNode);
}
// Process scan node.
// Set up the scan plan node's scan columns. Add in-line projection node for scan node.
scanNode.addInlinePlanNode(m_scanInlinedProjectionNode);
m_scanNode = scanNode;
return true;
} else {
boolean replaced = processScanNodeWithReAggNode(child, reAggNode);
if (replaced) {
return true;
}
}
}
return false;
}
use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class testPlannerTester method testGetScanNodeList.
/// Unit test some of the techniques used by plannerTester
public void testGetScanNodeList() {
AbstractPlanNode pn = null;
pn = compile("select * from l where lname=? and b=0 order by id asc limit ?;");
ArrayList<AbstractScanPlanNode> collected = pn.getScanNodeList();
System.out.println(collected);
System.out.println(collected.size());
for (AbstractPlanNode n : collected) {
System.out.println(n.toExplainPlanString());
}
assertTrue(collected.size() == 1);
JSONObject j;
try {
j = new JSONObject(collected.get(0).toJSONString());
System.out.println(j.getString("PLAN_NODE_TYPE"));
assertTrue(j.getString("PLAN_NODE_TYPE").equalsIgnoreCase("INDEXSCAN"));
} catch (JSONException e) {
e.printStackTrace();
}
}
Aggregations