use of org.apache.asterix.lang.sqlpp.clause.SelectSetOperation in project asterixdb by apache.
the class SqlppExpressionToPlanTranslator method visit.
@Override
public Pair<ILogicalOperator, LogicalVariable> visit(SelectSetOperation selectSetOperation, Mutable<ILogicalOperator> tupSource) throws CompilationException {
SetOperationInput leftInput = selectSetOperation.getLeftInput();
if (!selectSetOperation.hasRightInputs()) {
return leftInput.accept(this, tupSource);
}
List<ILangExpression> inputExprs = new ArrayList<>();
inputExprs.add(leftInput.selectBlock() ? new SelectExpression(null, new SelectSetOperation(leftInput, null), null, null, true) : leftInput.getSubquery());
for (SetOperationRight setOperationRight : selectSetOperation.getRightInputs()) {
SetOpType setOpType = setOperationRight.getSetOpType();
if (setOpType != SetOpType.UNION || setOperationRight.isSetSemantics()) {
throw new CompilationException("Operation " + setOpType + (setOperationRight.isSetSemantics() ? " with set semantics" : "ALL") + " is not supported.");
}
SetOperationInput rightInput = setOperationRight.getSetOperationRightInput();
inputExprs.add(rightInput.selectBlock() ? new SelectExpression(null, new SelectSetOperation(rightInput, null), null, null, true) : rightInput.getSubquery());
}
return translateUnionAllFromInputExprs(inputExprs, tupSource);
}
use of org.apache.asterix.lang.sqlpp.clause.SelectSetOperation in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public SelectExpression visit(SelectExpression selectExpression, Void arg) throws CompilationException {
List<LetClause> lets = new ArrayList<>();
SelectSetOperation select;
OrderbyClause orderby = null;
LimitClause limit = null;
// visit let list
if (selectExpression.hasLetClauses()) {
for (LetClause letClause : selectExpression.getLetList()) {
lets.add((LetClause) letClause.accept(this, arg));
}
}
// visit the main select.
select = (SelectSetOperation) selectExpression.getSelectSetOperation().accept(this, arg);
// visit order by
if (selectExpression.hasOrderby()) {
List<Expression> orderExprs = new ArrayList<>();
for (Expression orderExpr : selectExpression.getOrderbyClause().getOrderbyList()) {
orderExprs.add((Expression) orderExpr.accept(this, arg));
}
orderby = new OrderbyClause(orderExprs, selectExpression.getOrderbyClause().getModifierList());
}
// visit limit
if (selectExpression.hasLimit()) {
limit = (LimitClause) selectExpression.getLimitClause().accept(this, arg);
}
return new SelectExpression(lets, select, orderby, limit, selectExpression.isSubquery());
}
use of org.apache.asterix.lang.sqlpp.clause.SelectSetOperation in project asterixdb by apache.
the class SqlppCloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(SelectExpression selectExpression, VariableSubstitutionEnvironment env) throws CompilationException {
boolean subquery = selectExpression.isSubquery();
List<LetClause> newLetList = new ArrayList<>();
SelectSetOperation newSelectSetOperation;
OrderbyClause newOrderbyClause = null;
LimitClause newLimitClause = null;
VariableSubstitutionEnvironment currentEnv = env;
Pair<ILangExpression, VariableSubstitutionEnvironment> p;
if (selectExpression.hasLetClauses()) {
for (LetClause letClause : selectExpression.getLetList()) {
p = letClause.accept(this, currentEnv);
newLetList.add(letClause);
currentEnv = p.second;
}
}
p = selectExpression.getSelectSetOperation().accept(this, env);
newSelectSetOperation = (SelectSetOperation) p.first;
currentEnv = p.second;
if (selectExpression.hasOrderby()) {
p = selectExpression.getOrderbyClause().accept(this, currentEnv);
newOrderbyClause = (OrderbyClause) p.first;
currentEnv = p.second;
}
if (selectExpression.hasLimit()) {
p = selectExpression.getLimitClause().accept(this, currentEnv);
newLimitClause = (LimitClause) p.first;
currentEnv = p.second;
}
return new Pair<>(new SelectExpression(newLetList, newSelectSetOperation, newOrderbyClause, newLimitClause, subquery), currentEnv);
}
Aggregations