Search in sources :

Example 1 with Lateral

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

the class TestSqlParser method testLateral.

@Test
public void testLateral() {
    Lateral lateralRelation = new Lateral(query(new Values(ImmutableList.of(new LongLiteral("1")))));
    assertStatement("SELECT * FROM t, LATERAL (VALUES 1) a(x)", simpleQuery(selectList(new AllColumns()), new Join(Join.Type.IMPLICIT, new Table(QualifiedName.of("t")), new AliasedRelation(lateralRelation, identifier("a"), ImmutableList.of(identifier("x"))), Optional.empty())));
    assertStatement("SELECT * FROM t CROSS JOIN LATERAL (VALUES 1) ", simpleQuery(selectList(new AllColumns()), new Join(Join.Type.CROSS, new Table(QualifiedName.of("t")), lateralRelation, Optional.empty())));
    assertStatement("SELECT * FROM t FULL JOIN LATERAL (VALUES 1) ON true", simpleQuery(selectList(new AllColumns()), new Join(Join.Type.FULL, new Table(QualifiedName.of("t")), lateralRelation, 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) LongLiteral(io.trino.sql.tree.LongLiteral) Lateral(io.trino.sql.tree.Lateral) Values(io.trino.sql.tree.Values) NaturalJoin(io.trino.sql.tree.NaturalJoin) Join(io.trino.sql.tree.Join) AllColumns(io.trino.sql.tree.AllColumns) JoinOn(io.trino.sql.tree.JoinOn) AliasedRelation(io.trino.sql.tree.AliasedRelation) Test(org.junit.jupiter.api.Test)

Aggregations

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 Join (io.trino.sql.tree.Join)1 JoinOn (io.trino.sql.tree.JoinOn)1 Lateral (io.trino.sql.tree.Lateral)1 LongLiteral (io.trino.sql.tree.LongLiteral)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 Values (io.trino.sql.tree.Values)1 Test (org.junit.jupiter.api.Test)1