Search in sources :

Example 6 with SetOperationInput

use of org.apache.asterix.lang.sqlpp.struct.SetOperationInput 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);
}
Also used : CompilationException(org.apache.asterix.common.exceptions.CompilationException) SetOperationInput(org.apache.asterix.lang.sqlpp.struct.SetOperationInput) SelectSetOperation(org.apache.asterix.lang.sqlpp.clause.SelectSetOperation) SetOpType(org.apache.asterix.lang.sqlpp.optype.SetOpType) ArrayList(java.util.ArrayList) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) SelectExpression(org.apache.asterix.lang.sqlpp.expression.SelectExpression) SetOperationRight(org.apache.asterix.lang.sqlpp.struct.SetOperationRight)

Aggregations

SelectSetOperation (org.apache.asterix.lang.sqlpp.clause.SelectSetOperation)6 SelectExpression (org.apache.asterix.lang.sqlpp.expression.SelectExpression)6 SetOperationInput (org.apache.asterix.lang.sqlpp.struct.SetOperationInput)6 SelectBlock (org.apache.asterix.lang.sqlpp.clause.SelectBlock)5 ArrayList (java.util.ArrayList)4 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)3 VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)3 FromClause (org.apache.asterix.lang.sqlpp.clause.FromClause)3 FromTerm (org.apache.asterix.lang.sqlpp.clause.FromTerm)3 SelectClause (org.apache.asterix.lang.sqlpp.clause.SelectClause)3 SelectElement (org.apache.asterix.lang.sqlpp.clause.SelectElement)3 SetOperationRight (org.apache.asterix.lang.sqlpp.struct.SetOperationRight)3 Expression (org.apache.asterix.lang.common.base.Expression)2 HashMap (java.util.HashMap)1 CompilationException (org.apache.asterix.common.exceptions.CompilationException)1 FunctionSignature (org.apache.asterix.common.functions.FunctionSignature)1 LimitClause (org.apache.asterix.lang.common.clause.LimitClause)1 OrderbyClause (org.apache.asterix.lang.common.clause.OrderbyClause)1 WhereClause (org.apache.asterix.lang.common.clause.WhereClause)1 CallExpr (org.apache.asterix.lang.common.expression.CallExpr)1