Java 类com.facebook.presto.sql.tree.Union 实例源码

项目:presto-query-formatter    文件:StatementFormatter.java   
@Override
protected Void visitUnion(Union node, Integer indent)
{
    Iterator<Relation> relations = node.getRelations().iterator();

    while (relations.hasNext()) {
        processRelation(relations.next(), indent);

        if (relations.hasNext()) {
            builder.append("UNION ");
            if (!node.isDistinct()) {
                builder.append("ALL ");
            }
        }
    }

    return null;
}
项目:presto    文件:SqlFormatter.java   
@Override
protected Void visitUnion(Union node, Integer indent)
{
    Iterator<Relation> relations = node.getRelations().iterator();

    while (relations.hasNext()) {
        processRelation(relations.next(), indent);

        if (relations.hasNext()) {
            builder.append("UNION ");
            if (!node.isDistinct()) {
                builder.append("ALL ");
            }
        }
    }

    return null;
}
项目:presto    文件:AstBuilder.java   
@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());
}
项目:EchoQuery    文件:SqlFormatter.java   
@Override
protected Void visitUnion(Union node, Integer indent)
{
    Iterator<Relation> relations = node.getRelations().iterator();

    while (relations.hasNext()) {
        processRelation(relations.next(), indent);

        if (relations.hasNext()) {
            builder.append("UNION ");
            if (!node.isDistinct()) {
                builder.append("ALL ");
            }
        }
    }

    return null;
}
项目:presto    文件:TestSqlParser.java   
@Test
public void testUnion()
{
    assertStatement("SELECT 123 UNION DISTINCT SELECT 123 UNION ALL SELECT 123",
            new Query(
                    Optional.empty(),
                    new Union(ImmutableList.of(
                            new Union(ImmutableList.of(createSelect123(), createSelect123()), true),
                            createSelect123()
                    ), false),
                    ImmutableList.<SortItem>of(),
                    Optional.empty(),
                    Optional.empty()));
}