use of org.voltdb.planner.ParsedUnionStmt in project voltdb by VoltDB.
the class StmtSubqueryScan method canRunInOneFragment.
/**
* Some subquery results can only be joined with a partitioned table after
* it finishes some work on the coordinator. With the 2 fragment plan limit,
* those queries can not be supported.
* Other than that case, the planner will typically have added a
* send/receive pair to the subquery plan that is actually only suitable to
* a stand-alone plan. This function distinguishes subqueries that should NOT
* have a send/receive pair.
* @param root
* @return true if there is no aspect to the plan that requires execution on the coordinator.
*/
public boolean canRunInOneFragment() {
assert (m_subqueriesPartitioning != null);
assert (m_subqueryStmt != null);
if (m_subqueriesPartitioning.getCountOfPartitionedTables() == 0) {
return true;
}
// of their results.
if (failsSingleFragmentTest()) {
return false;
}
// Tentative assignment in case of early return.
// This gets immediately reset if it passes all the tests.
m_failedSingleFragmentTest = true;
if (m_subqueryStmt instanceof ParsedUnionStmt) {
// Union are just returned
return false;
}
if (!(m_subqueryStmt instanceof ParsedSelectStmt)) {
throw new PlanningErrorException("Unsupported subquery found in FROM clause:" + m_subqueryStmt);
}
ParsedSelectStmt selectStmt = (ParsedSelectStmt) m_subqueryStmt;
// we should get rid of the receive node. I (--paul) don't know what this means.
if (selectStmt.hasLimitOrOffset() || selectStmt.hasDistinctWithGroupBy()) {
return false;
}
// because it contains a partitioned view that does not have a partition column.
if (selectStmt.m_mvFixInfo.needed()) {
return false;
}
// Table aggregate cases should not get rid of the receive node
if (selectStmt.hasAggregateOrGroupby()) {
if (!selectStmt.isGrouped()) {
m_tableAggregateSubquery = true;
return false;
}
// Detect case (1) to mark receive node.
if (!selectStmt.hasPartitionColumnInGroupby()) {
return false;
}
}
if (!selectStmt.hasPartitionColumnInWindowFunctionExpression()) {
return false;
}
// Now. If this sub-query joins with a partitioned table in the parent statement,
// push the join down by removing the send/receive plan node pair.
m_failedSingleFragmentTest = false;
return true;
}
Aggregations