Search in sources :

Example 76 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class KafkaAvroSmokeTest method testSelectStructuralDataType.

@Test(groups = { KAFKA })
@Requires(StructuralDataTypeTable.class)
public void testSelectStructuralDataType() throws SQLException {
    QueryResult queryResult = query(format("SELECT a[1], a[2], m['key1'] FROM (SELECT c_array as a, c_map as m FROM %s.%s) t", KAFKA_CATALOG, STRUCTURAL_AVRO_TABLE_NAME));
    assertThat(queryResult).containsOnly(row(100, 102, "value1"));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest) Requires(io.prestodb.tempto.Requires)

Example 77 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class TestRoles method testListRoles.

@Test(groups = { ROLES, AUTHORIZATION, PROFILE_SPECIFIC_TESTS })
public void testListRoles() {
    onPresto().executeQuery(format("CREATE ROLE %s", ROLE1));
    QueryResult expected = onHive().executeQuery("SHOW ROLES");
    QueryResult actual = onPresto().executeQuery("SELECT * FROM hive.information_schema.roles");
    assertThat(actual.rows()).containsOnly(expected.rows().toArray(new List[] {}));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 78 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class TestTablePartitioningInsertInto method testQuerySplitsNumber.

private void testQuerySplitsNumber(String condition, int expectedProcessedSplits) throws Exception {
    String partitionedNation = mutableTablesState().get(NATION_PARTITIONED_BY_BIGINT_REGIONKEY.getTableHandle()).getNameInDatabase();
    String targetNation = mutableTablesState().get(TARGET_NATION_NAME).getNameInDatabase();
    String query = String.format("INSERT INTO %s SELECT p_nationkey, p_name, p_regionkey, p_comment FROM %s WHERE %s", targetNation, partitionedNation, condition);
    QueryResult queryResult = query(query);
    long processedLinesCount = getProcessedLinesCount(query, queryResult);
    int expectedLinesCount = expectedProcessedSplits * NATION_PARTITIONED_BY_REGIONKEY_NUMBER_OF_LINES_PER_SPLIT;
    assertThat(processedLinesCount).isEqualTo(expectedLinesCount);
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult)

Example 79 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class TestTablePartitioningSelect method testSelectPartitionedHiveTableDifferentFormats.

@Test
public void testSelectPartitionedHiveTableDifferentFormats() {
    String tableNameInDatabase = tablesState.get(TABLE_NAME).getNameInDatabase();
    String selectFromOnePartitionsSql = "SELECT * FROM " + tableNameInDatabase + " WHERE part_col = 2";
    QueryResult onePartitionQueryResult = query(selectFromOnePartitionsSql);
    assertThat(onePartitionQueryResult).containsOnly(row(42, 2));
    try {
        // This query should fail or return null values for invalid partition data
        assertThat(query("SELECT * FROM " + tableNameInDatabase)).containsOnly(row(42, 2), row(null, 1));
    } catch (QueryExecutionException expectedDueToInvalidPartitionData) {
    }
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) QueryExecutionException(io.prestodb.tempto.query.QueryExecutionException) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 80 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class TestSelect method testAllDatatypes.

@Test(groups = { SQL_SERVER, PROFILE_SPECIFIC_TESTS })
public void testAllDatatypes() {
    String sql = format("SELECT bi, si, i, ti, f, r, c, vc, te, nc, nvc, nt, d, dt, dt2, sdt, pf30, pf22 " + "FROM %s", ALL_TYPES_TABLE_NAME);
    QueryResult queryResult = onPresto().executeQuery(sql);
    assertThat(queryResult).hasColumns(BIGINT, SMALLINT, INTEGER, TINYINT, DOUBLE, REAL, CHAR, VARCHAR, VARCHAR, CHAR, VARCHAR, VARCHAR, DATE, TIMESTAMP, TIMESTAMP, TIMESTAMP, DOUBLE, REAL).containsOnly(row(Long.MIN_VALUE, Short.MIN_VALUE, Integer.MIN_VALUE, Byte.MIN_VALUE, Double.MIN_VALUE, Float.valueOf("-3.40E+38"), "\0   ", "\0", "\0", "\0    ", "\0", "\0", Date.valueOf("0001-01-02"), Timestamp.valueOf("1753-01-01 00:00:00.000"), Timestamp.valueOf("0001-01-01 00:00:00.000"), Timestamp.valueOf("1900-01-01 00:00:00"), Double.MIN_VALUE, Float.valueOf("-3.40E+38")), row(Long.MAX_VALUE, Short.MAX_VALUE, Integer.MAX_VALUE, Byte.MAX_VALUE, Double.MAX_VALUE, Float.MAX_VALUE, "abcd", "abcdef", "abcd", "abcde", "abcdefg", "abcd", Date.valueOf("9999-12-31"), Timestamp.valueOf("9999-12-31 23:59:59.997"), Timestamp.valueOf("9999-12-31 23:59:59.999"), Timestamp.valueOf("2079-06-06 00:00:00"), Double.valueOf("12345678912.3456756"), Float.valueOf("12345678.6557")), row(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null));
}
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