Search in sources :

Example 1 with WithQuery

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

the class TestSqlParser method testWith.

@Test
public void testWith() throws Exception {
    assertStatement("WITH a (t, u) AS (SELECT * FROM x), b AS (SELECT * FROM y) TABLE z", new Query(Optional.of(new With(false, ImmutableList.of(new WithQuery("a", simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("x"))), Optional.of(ImmutableList.of("t", "u"))), new WithQuery("b", simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("y"))), Optional.empty())))), new Table(QualifiedName.of("z")), Optional.empty(), Optional.empty()));
    assertStatement("WITH RECURSIVE a AS (SELECT * FROM x) TABLE y", new Query(Optional.of(new With(true, ImmutableList.of(new WithQuery("a", simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("x"))), Optional.empty())))), new Table(QualifiedName.of("y")), Optional.empty(), Optional.empty()));
}
Also used : CreateTable(com.facebook.presto.sql.tree.CreateTable) DropTable(com.facebook.presto.sql.tree.DropTable) Table(com.facebook.presto.sql.tree.Table) RenameTable(com.facebook.presto.sql.tree.RenameTable) Query(com.facebook.presto.sql.tree.Query) QueryUtil.simpleQuery(com.facebook.presto.sql.QueryUtil.simpleQuery) WithQuery(com.facebook.presto.sql.tree.WithQuery) WithQuery(com.facebook.presto.sql.tree.WithQuery) AllColumns(com.facebook.presto.sql.tree.AllColumns) With(com.facebook.presto.sql.tree.With) Test(org.testng.annotations.Test)

Aggregations

QueryUtil.simpleQuery (com.facebook.presto.sql.QueryUtil.simpleQuery)1 AllColumns (com.facebook.presto.sql.tree.AllColumns)1 CreateTable (com.facebook.presto.sql.tree.CreateTable)1 DropTable (com.facebook.presto.sql.tree.DropTable)1 Query (com.facebook.presto.sql.tree.Query)1 RenameTable (com.facebook.presto.sql.tree.RenameTable)1 Table (com.facebook.presto.sql.tree.Table)1 With (com.facebook.presto.sql.tree.With)1 WithQuery (com.facebook.presto.sql.tree.WithQuery)1 Test (org.testng.annotations.Test)1