Search in sources :

Example 1 with Union

use of com.facebook.presto.sql.tree.Union in project presto by prestodb.

the class AstBuilder method visitSetOperation.

@Override
public Node visitSetOperation(SqlBaseParser.SetOperationContext context) {
    QueryBody left = (QueryBody) visit(context.left);
    QueryBody right = (QueryBody) visit(context.right);
    boolean distinct = context.setQuantifier() == null || context.setQuantifier().DISTINCT() != null;
    switch(context.operator.getType()) {
        case SqlBaseLexer.UNION:
            return new Union(getLocation(context.UNION()), ImmutableList.of(left, right), distinct);
        case SqlBaseLexer.INTERSECT:
            return new Intersect(getLocation(context.INTERSECT()), ImmutableList.of(left, right), distinct);
        case SqlBaseLexer.EXCEPT:
            return new Except(getLocation(context.EXCEPT()), left, right, distinct);
    }
    throw new IllegalArgumentException("Unsupported set operation: " + context.operator.getText());
}
Also used : Intersect(com.facebook.presto.sql.tree.Intersect) QueryBody(com.facebook.presto.sql.tree.QueryBody) Union(com.facebook.presto.sql.tree.Union) Except(com.facebook.presto.sql.tree.Except)

Aggregations

Except (com.facebook.presto.sql.tree.Except)1 Intersect (com.facebook.presto.sql.tree.Intersect)1 QueryBody (com.facebook.presto.sql.tree.QueryBody)1 Union (com.facebook.presto.sql.tree.Union)1