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

项目:presto    文件:TestSqlParser.java   
@Test
public void testJoinPrecedence()
{
    assertStatement("SELECT * FROM a CROSS JOIN b LEFT JOIN c ON true",
            simpleQuery(
                    selectList(new AllColumns()),
                    new Join(
                            Join.Type.LEFT,
                            new Join(
                                    Join.Type.CROSS,
                                    new Table(QualifiedName.of("a")),
                                    new Table(QualifiedName.of("b")),
                                    Optional.empty()
                            ),
                            new Table(QualifiedName.of("c")),
                            Optional.of(new JoinOn(BooleanLiteral.TRUE_LITERAL)))));
    assertStatement("SELECT * FROM a CROSS JOIN b NATURAL JOIN c CROSS JOIN d NATURAL JOIN e",
            simpleQuery(
                    selectList(new AllColumns()),
                    new Join(
                            Join.Type.INNER,
                            new Join(
                                    Join.Type.CROSS,
                                    new Join(
                                            Join.Type.INNER,
                                            new Join(
                                                    Join.Type.CROSS,
                                                    new Table(QualifiedName.of("a")),
                                                    new Table(QualifiedName.of("b")),
                                                    Optional.empty()
                                            ),
                                            new Table(QualifiedName.of("c")),
                                            Optional.of(new NaturalJoin())),
                                    new Table(QualifiedName.of("d")),
                                    Optional.empty()
                            ),
                            new Table(QualifiedName.of("e")),
                            Optional.of(new NaturalJoin()))));
}