Search in sources :

Example 26 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class CreateTableAsSelect method testCreateTableAsSelect.

@Requires(ImmutableNationTable.class)
@Test(groups = { JDBC, MYSQL })
public void testCreateTableAsSelect() {
    QueryResult queryResult = query(format("CREATE TABLE mysql.%s AS SELECT * FROM nation", TABLE_NAME));
    assertThat(queryResult).containsOnly(row(25));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Requires(io.prestodb.tempto.Requires) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 27 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestInsert method testInsertMin.

@Test(groups = { SQL_SERVER, PROFILE_SPECIFIC_TESTS })
public void testInsertMin() {
    String sql = format("INSERT INTO %s.%s values (BIGINT '%s', SMALLINT '%s', INTEGER '%s', DOUBLE '%s', " + "CHAR 'a   ', 'aa', DOUBLE '%s', DATE '%s')", SQLSERVER, INSERT_TABLE_NAME, Long.valueOf("-9223372036854775807"), Short.MIN_VALUE, Integer.MIN_VALUE, Double.MIN_VALUE, Double.MIN_VALUE, Date.valueOf("1970-01-01"));
    // Min value for BIGINT would be updated to "-9223372036854775808" post https://github.com/prestodb/presto/issues/4571
    onPresto().executeQuery(sql);
    sql = format("SELECT * FROM %s.%s", MASTER, INSERT_TABLE_NAME);
    QueryResult queryResult = onSqlServer().executeQuery(sql);
    assertThat(queryResult).contains(row(Long.valueOf("-9223372036854775807"), Short.MIN_VALUE, Integer.MIN_VALUE, Double.MIN_VALUE, "a   ", "aa", Double.MIN_VALUE, Date.valueOf("1970-01-01")));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 28 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestInsert method testInsertMax.

@Test(groups = { SQL_SERVER, PROFILE_SPECIFIC_TESTS })
public void testInsertMax() {
    String sql = format("INSERT INTO %s.%s values (BIGINT '%s', SMALLINT '%s', INTEGER '%s', DOUBLE '%s', " + "CHAR 'aaaa', 'aaaaaa', DOUBLE '%s', DATE '%s' )", SQLSERVER, INSERT_TABLE_NAME, Long.MAX_VALUE, Short.MAX_VALUE, Integer.MAX_VALUE, Double.MAX_VALUE, Double.valueOf("12345678912.3456756"), Date.valueOf("9999-12-31"));
    onPresto().executeQuery(sql);
    sql = format("SELECT * FROM %s.%s", MASTER, INSERT_TABLE_NAME);
    QueryResult queryResult = onSqlServer().executeQuery(sql);
    assertThat(queryResult).contains(row(Long.MAX_VALUE, Short.MAX_VALUE, Integer.MAX_VALUE, Double.MAX_VALUE, "aaaa", "aaaaaa", Double.valueOf("12345678912.3456756"), Date.valueOf("9999-12-31")));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 29 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestSelect method testNationSelfInnerJoin.

@Test(groups = { SQL_SERVER, PROFILE_SPECIFIC_TESTS })
public void testNationSelfInnerJoin() {
    String sql = format("SELECT n1.n_name, n2.n_regionkey FROM %s n1 JOIN " + "%s n2 ON n1.n_nationkey = n2.n_regionkey " + "WHERE n1.n_nationkey=3", NATION_TABLE_NAME, NATION_TABLE_NAME);
    QueryResult queryResult = onPresto().executeQuery(sql);
    assertThat(queryResult).containsOnly(row("CANADA", 3), row("CANADA", 3), row("CANADA", 3), row("CANADA", 3), row("CANADA", 3));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 30 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestSelect method testCreateTableAsSelect.

@Test(groups = { SQL_SERVER, PROFILE_SPECIFIC_TESTS })
public void testCreateTableAsSelect() {
    String sql = format("CREATE TABLE %s AS SELECT * FROM %s", CREATE_TABLE_AS_SELECT, NATION_TABLE_NAME);
    onPresto().executeQuery(sql);
    sql = format("SELECT n_nationkey, n_name, n_regionkey, n_comment FROM %s.%s.%s", "master", KEY_SPACE, CTAS_TABLE_NAME);
    QueryResult queryResult = onSqlServer().executeQuery(sql);
    assertThat(queryResult).matches(PRESTO_NATION_RESULT);
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Aggregations

QueryResult (io.prestodb.tempto.query.QueryResult)122 Test (org.testng.annotations.Test)110 ProductTest (io.prestodb.tempto.ProductTest)108 Requires (io.prestodb.tempto.Requires)38 BigDecimal (java.math.BigDecimal)14 Statement (java.sql.Statement)12 PreparedStatement (java.sql.PreparedStatement)8 Duration (io.airlift.units.Duration)6 Row (io.prestodb.tempto.assertions.QueryAssert.Row)6 List (java.util.List)6 STORAGE_FORMATS (com.facebook.presto.tests.TestGroups.STORAGE_FORMATS)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 Row.row (io.prestodb.tempto.assertions.QueryAssert.Row.row)4 QueryAssert.assertThat (io.prestodb.tempto.assertions.QueryAssert.assertThat)4 QueryExecutor.query (io.prestodb.tempto.query.QueryExecutor.query)4 String.format (java.lang.String.format)4 Connection (java.sql.Connection)4 Response (com.facebook.airlift.http.client.Response)2 PrestoConnection (com.facebook.presto.jdbc.PrestoConnection)2 JdbcDriverUtils (com.facebook.presto.tests.utils.JdbcDriverUtils)2