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));
}
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)))));
}
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"))));
}
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"));
}
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"));
}
Aggregations