Search in sources :

Example 1 with Except

use of com.facebook.presto.sql.tree.Except 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);
    Optional<Boolean> distinct = Optional.empty();
    if (context.setQuantifier() != null) {
        if (context.setQuantifier().DISTINCT() != null) {
            distinct = Optional.of(true);
        } else if (context.setQuantifier().ALL() != null) {
            distinct = Optional.of(false);
        }
    }
    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)

Example 2 with Except

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

the class PredicateStitcher method visitExcept.

@Override
protected Node visitExcept(Except node, PredicateStitcherContext context) {
    Relation rewrittenLeft = (Relation) process(node.getLeft(), context);
    Relation rewrittenRight = (Relation) process(node.getRight(), context);
    return new Except(rewrittenLeft, rewrittenRight, node.isDistinct());
}
Also used : AliasedRelation(com.facebook.presto.sql.tree.AliasedRelation) Relation(com.facebook.presto.sql.tree.Relation) SampledRelation(com.facebook.presto.sql.tree.SampledRelation) Except(com.facebook.presto.sql.tree.Except)

Aggregations

Except (com.facebook.presto.sql.tree.Except)2 AliasedRelation (com.facebook.presto.sql.tree.AliasedRelation)1 Intersect (com.facebook.presto.sql.tree.Intersect)1 QueryBody (com.facebook.presto.sql.tree.QueryBody)1 Relation (com.facebook.presto.sql.tree.Relation)1 SampledRelation (com.facebook.presto.sql.tree.SampledRelation)1 Union (com.facebook.presto.sql.tree.Union)1