Search in sources :

Example 1 with Except

use of io.prestosql.sql.tree.Except in project hetu-core by openlookeng.

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(io.prestosql.sql.tree.Intersect) QueryBody(io.prestosql.sql.tree.QueryBody) Union(io.prestosql.sql.tree.Union) Except(io.prestosql.sql.tree.Except)

Example 2 with Except

use of io.prestosql.sql.tree.Except in project hetu-core by openlookeng.

the class HiveAstBuilder method visitSetOperation.

@Override
public Node visitSetOperation(HiveSqlParser.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 HiveSqlLexer.UNION:
            return new Union(getLocation(context.UNION()), ImmutableList.of(left, right), distinct);
        case HiveSqlLexer.INTERSECT:
            return new Intersect(getLocation(context.INTERSECT()), ImmutableList.of(left, right), distinct);
        case HiveSqlLexer.EXCEPT:
            return new Except(getLocation(context.EXCEPT()), left, right, distinct);
    }
    throw new IllegalArgumentException("Unsupported set operation: " + context.operator.getText());
}
Also used : Intersect(io.prestosql.sql.tree.Intersect) QueryBody(io.prestosql.sql.tree.QueryBody) Union(io.prestosql.sql.tree.Union) Except(io.prestosql.sql.tree.Except)

Example 3 with Except

use of io.prestosql.sql.tree.Except in project hetu-core by openlookeng.

the class ImpalaAstBuilder method visitSetOperation.

@Override
public Node visitSetOperation(ImpalaSqlParser.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 ImpalaSqlLexer.UNION:
            return new Union(getLocation(context.UNION()), ImmutableList.of(left, right), distinct);
        case ImpalaSqlLexer.INTERSECT:
            return new Intersect(getLocation(context.INTERSECT()), ImmutableList.of(left, right), distinct);
        case ImpalaSqlLexer.EXCEPT:
            return new Except(getLocation(context.EXCEPT()), left, right, distinct);
    }
    throw new IllegalArgumentException("Unsupported set operation: " + context.operator.getText());
}
Also used : Intersect(io.prestosql.sql.tree.Intersect) QueryBody(io.prestosql.sql.tree.QueryBody) Union(io.prestosql.sql.tree.Union) Except(io.prestosql.sql.tree.Except)

Aggregations

Except (io.prestosql.sql.tree.Except)3 Intersect (io.prestosql.sql.tree.Intersect)3 QueryBody (io.prestosql.sql.tree.QueryBody)3 Union (io.prestosql.sql.tree.Union)3