use of org.apache.phoenix.execute.UnionPlan in project phoenix by apache.
the class QueryCompiler method compileUnionAll.
public QueryPlan compileUnionAll(SelectStatement select) throws SQLException {
List<SelectStatement> unionAllSelects = select.getSelects();
List<QueryPlan> plans = new ArrayList<QueryPlan>();
for (int i = 0; i < unionAllSelects.size(); i++) {
SelectStatement subSelect = unionAllSelects.get(i);
// Push down order-by and limit into sub-selects.
if (!select.getOrderBy().isEmpty() || select.getLimit() != null) {
if (select.getOffset() == null) {
subSelect = NODE_FACTORY.select(subSelect, select.getOrderBy(), select.getLimit(), null);
} else {
subSelect = NODE_FACTORY.select(subSelect, select.getOrderBy(), null, null);
}
}
QueryPlan subPlan = compileSubquery(subSelect, true);
plans.add(subPlan);
}
TableRef tableRef = UnionCompiler.contructSchemaTable(statement, plans, select.hasWildcard() ? null : select.getSelect());
ColumnResolver resolver = FromCompiler.getResolver(tableRef);
StatementContext context = new StatementContext(statement, resolver, scan, sequenceManager);
QueryPlan plan = compileSingleFlatQuery(context, select, statement.getParameters(), false, false, null, null, false);
plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOffset(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, plans, context.getBindManager().getParameterMetaData());
return plan;
}
Aggregations