Search in sources :

Example 16 with AllColumns

use of io.prestosql.sql.tree.AllColumns in project hetu-core by openlookeng.

the class TestSqlParser method testInsertInto.

@Test
public void testInsertInto() {
    QualifiedName table = QualifiedName.of("a");
    Query query = simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t")));
    assertStatement("INSERT INTO a SELECT * FROM t", new Insert(table, Optional.empty(), query));
    assertStatement("INSERT INTO a (c1, c2) SELECT * FROM t", new Insert(table, Optional.of(ImmutableList.of(identifier("c1"), identifier("c2"))), query));
}
Also used : QueryUtil.simpleQuery(io.prestosql.sql.QueryUtil.simpleQuery) Query(io.prestosql.sql.tree.Query) WithQuery(io.prestosql.sql.tree.WithQuery) QualifiedName(io.prestosql.sql.tree.QualifiedName) AllColumns(io.prestosql.sql.tree.AllColumns) Insert(io.prestosql.sql.tree.Insert) Test(org.testng.annotations.Test)

Example 17 with AllColumns

use of io.prestosql.sql.tree.AllColumns in project hetu-core by openlookeng.

the class TestSqlParser method testLateral.

@Test
public void testLateral() {
    Lateral lateralRelation = new Lateral(new Query(Optional.empty(), new Values(ImmutableList.of(new LongLiteral("1"))), Optional.empty(), Optional.empty(), Optional.empty()));
    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 : Table(io.prestosql.sql.tree.Table) CreateTable(io.prestosql.sql.tree.CreateTable) VacuumTable(io.prestosql.sql.tree.VacuumTable) DropTable(io.prestosql.sql.tree.DropTable) RenameTable(io.prestosql.sql.tree.RenameTable) QueryUtil.simpleQuery(io.prestosql.sql.QueryUtil.simpleQuery) Query(io.prestosql.sql.tree.Query) WithQuery(io.prestosql.sql.tree.WithQuery) LongLiteral(io.prestosql.sql.tree.LongLiteral) Lateral(io.prestosql.sql.tree.Lateral) Values(io.prestosql.sql.tree.Values) Join(io.prestosql.sql.tree.Join) NaturalJoin(io.prestosql.sql.tree.NaturalJoin) AllColumns(io.prestosql.sql.tree.AllColumns) JoinOn(io.prestosql.sql.tree.JoinOn) AliasedRelation(io.prestosql.sql.tree.AliasedRelation) Test(org.testng.annotations.Test)

Example 18 with AllColumns

use of io.prestosql.sql.tree.AllColumns in project hetu-core by openlookeng.

the class TestQueryPreparer method testExecuteStatement.

@Test
public void testExecuteStatement() {
    Session session = testSessionBuilder().addPreparedStatement("my_query", "SELECT * FROM foo").build();
    PreparedQuery preparedQuery = QUERY_PREPARER.prepareQuery(session, "EXECUTE my_query");
    assertEquals(preparedQuery.getStatement(), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo"))));
}
Also used : PreparedQuery(io.prestosql.execution.QueryPreparer.PreparedQuery) AllColumns(io.prestosql.sql.tree.AllColumns) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 19 with AllColumns

use of io.prestosql.sql.tree.AllColumns in project hetu-core by openlookeng.

the class TestPrepareTask method testPrepareNameExists.

@Test
public void testPrepareNameExists() {
    Session session = testSessionBuilder().addPreparedStatement("my_query", "SELECT bar, baz from foo").build();
    Query query = simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo")));
    String sqlString = "PREPARE my_query FROM SELECT * FROM foo";
    Map<String, String> statements = executePrepare("my_query", query, sqlString, session);
    assertEquals(statements, ImmutableMap.of("my_query", "SELECT *\nFROM\n  foo\n"));
}
Also used : QueryUtil.simpleQuery(io.prestosql.sql.QueryUtil.simpleQuery) Query(io.prestosql.sql.tree.Query) AllColumns(io.prestosql.sql.tree.AllColumns) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 20 with AllColumns

use of io.prestosql.sql.tree.AllColumns in project hetu-core by openlookeng.

the class TestPrepareTask method testPrepare.

@Test
public void testPrepare() {
    Query query = simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo")));
    String sqlString = "PREPARE my_query FROM SELECT * FROM foo";
    Map<String, String> statements = executePrepare("my_query", query, sqlString, TEST_SESSION);
    assertEquals(statements, ImmutableMap.of("my_query", "SELECT *\nFROM\n  foo\n"));
}
Also used : QueryUtil.simpleQuery(io.prestosql.sql.QueryUtil.simpleQuery) Query(io.prestosql.sql.tree.Query) AllColumns(io.prestosql.sql.tree.AllColumns) Test(org.testng.annotations.Test)

Aggregations

AllColumns (io.prestosql.sql.tree.AllColumns)20 Test (org.testng.annotations.Test)19 Query (io.prestosql.sql.tree.Query)14 QueryUtil.simpleQuery (io.prestosql.sql.QueryUtil.simpleQuery)13 WithQuery (io.prestosql.sql.tree.WithQuery)11 Table (io.prestosql.sql.tree.Table)9 CreateTable (io.prestosql.sql.tree.CreateTable)8 DropTable (io.prestosql.sql.tree.DropTable)8 LongLiteral (io.prestosql.sql.tree.LongLiteral)8 RenameTable (io.prestosql.sql.tree.RenameTable)8 VacuumTable (io.prestosql.sql.tree.VacuumTable)8 StringLiteral (io.prestosql.sql.tree.StringLiteral)6 Identifier (io.prestosql.sql.tree.Identifier)5 QualifiedName (io.prestosql.sql.tree.QualifiedName)5 QuerySpecification (io.prestosql.sql.tree.QuerySpecification)5 QueryUtil.quotedIdentifier (io.prestosql.sql.QueryUtil.quotedIdentifier)4 AliasedRelation (io.prestosql.sql.tree.AliasedRelation)3 Session (io.prestosql.Session)2 PreparedQuery (io.prestosql.execution.QueryPreparer.PreparedQuery)2 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)2