Search in sources :

Example 1 with QuerySpecification

use of io.crate.sql.tree.QuerySpecification in project crate by crate.

the class AstBuilder method visitSetOperation.

@Override
public Node visitSetOperation(SqlBaseParser.SetOperationContext context) {
    switch(context.operator.getType()) {
        case SqlBaseLexer.UNION:
            QueryBody left = (QueryBody) visit(context.left);
            QueryBody right = (QueryBody) visit(context.right);
            boolean isDistinct = context.setQuant() == null || context.setQuant().ALL() == null;
            return new Union(left, right, isDistinct);
        case SqlBaseLexer.INTERSECT:
            QuerySpecification first = (QuerySpecification) visit(context.first);
            QuerySpecification second = (QuerySpecification) visit(context.second);
            return new Intersect(first, second);
        case SqlBaseLexer.EXCEPT:
            first = (QuerySpecification) visit(context.first);
            second = (QuerySpecification) visit(context.second);
            return new Except(first, second);
        default:
            throw new IllegalArgumentException("Unsupported set operation: " + context.operator.getText());
    }
}
Also used : QuerySpecification(io.crate.sql.tree.QuerySpecification) Intersect(io.crate.sql.tree.Intersect) QueryBody(io.crate.sql.tree.QueryBody) Union(io.crate.sql.tree.Union) Except(io.crate.sql.tree.Except)

Aggregations

Except (io.crate.sql.tree.Except)1 Intersect (io.crate.sql.tree.Intersect)1 QueryBody (io.crate.sql.tree.QueryBody)1 QuerySpecification (io.crate.sql.tree.QuerySpecification)1 Union (io.crate.sql.tree.Union)1