Search in sources :

Example 21 with QueryResult

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

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 22 with QueryResult

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

the class TestSyncPartitionMetadata method assertPartitions.

private static void assertPartitions(String tableName, QueryAssert.Row... rows) {
    QueryResult partitionListResult = query("SELECT * FROM \"" + tableName + "$partitions\" ORDER BY 1, 2");
    assertThat(partitionListResult).containsExactly(rows);
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult)

Example 23 with QueryResult

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

the class JdbcTests method shouldExecuteQueryWithSelectedCatalogAndSchema.

@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldExecuteQueryWithSelectedCatalogAndSchema() throws SQLException {
    if (usingTeradataJdbc4Driver(connection())) {
        LOGGER.warn("connection().setSchema() is not supported in JDBC 4");
    } else {
        connection().setCatalog("hive");
        connection().setSchema("default");
        try (Statement statement = connection().createStatement()) {
            QueryResult result = queryResult(statement, "select * from nation");
            assertThat(result).matches(PRESTO_NATION_RESULT);
        }
    }
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest) Requires(io.prestodb.tempto.Requires)

Example 24 with QueryResult

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

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 25 with QueryResult

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

the class KafkaAvroSmokeTest method testSelectPrimitiveDataType.

@Test(groups = { KAFKA })
@Requires(AllDataTypesAvroTable.class)
public void testSelectPrimitiveDataType() throws SQLException {
    QueryResult queryResult = query(format("select * from %s.%s", KAFKA_CATALOG, ALL_DATATYPES_AVRO_TABLE_NAME));
    assertThat(queryResult).containsOnly(row("foobar", 127, 234.567, true));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest) Requires(io.prestodb.tempto.Requires)

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