Search in sources :

Example 1 with Unnest

use of io.trino.sql.tree.Unnest in project trino by trinodb.

the class TestSqlParser method testUnnest.

@Test
public void testUnnest() {
    assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a)", simpleQuery(selectList(new AllColumns()), new Join(Join.Type.CROSS, new Table(QualifiedName.of("t")), new Unnest(ImmutableList.of(new Identifier("a")), false), Optional.empty())));
    assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a, b) WITH ORDINALITY", simpleQuery(selectList(new AllColumns()), new Join(Join.Type.CROSS, new Table(QualifiedName.of("t")), new Unnest(ImmutableList.of(new Identifier("a"), new Identifier("b")), true), Optional.empty())));
    assertStatement("SELECT * FROM t FULL JOIN UNNEST(a) AS tmp (c) ON true", simpleQuery(selectList(new AllColumns()), new Join(Join.Type.FULL, new Table(QualifiedName.of("t")), new AliasedRelation(new Unnest(ImmutableList.of(new Identifier("a")), false), new Identifier("tmp"), ImmutableList.of(new Identifier("c"))), Optional.of(new JoinOn(BooleanLiteral.TRUE_LITERAL)))));
}
Also used : CreateTable(io.trino.sql.tree.CreateTable) DropTable(io.trino.sql.tree.DropTable) Table(io.trino.sql.tree.Table) TruncateTable(io.trino.sql.tree.TruncateTable) RenameTable(io.trino.sql.tree.RenameTable) QueryUtil.quotedIdentifier(io.trino.sql.QueryUtil.quotedIdentifier) Identifier(io.trino.sql.tree.Identifier) NaturalJoin(io.trino.sql.tree.NaturalJoin) Join(io.trino.sql.tree.Join) AllColumns(io.trino.sql.tree.AllColumns) Unnest(io.trino.sql.tree.Unnest) JoinOn(io.trino.sql.tree.JoinOn) AliasedRelation(io.trino.sql.tree.AliasedRelation) Test(org.junit.jupiter.api.Test)

Aggregations

QueryUtil.quotedIdentifier (io.trino.sql.QueryUtil.quotedIdentifier)1 AliasedRelation (io.trino.sql.tree.AliasedRelation)1 AllColumns (io.trino.sql.tree.AllColumns)1 CreateTable (io.trino.sql.tree.CreateTable)1 DropTable (io.trino.sql.tree.DropTable)1 Identifier (io.trino.sql.tree.Identifier)1 Join (io.trino.sql.tree.Join)1 JoinOn (io.trino.sql.tree.JoinOn)1 NaturalJoin (io.trino.sql.tree.NaturalJoin)1 RenameTable (io.trino.sql.tree.RenameTable)1 Table (io.trino.sql.tree.Table)1 TruncateTable (io.trino.sql.tree.TruncateTable)1 Unnest (io.trino.sql.tree.Unnest)1 Test (org.junit.jupiter.api.Test)1