Search in sources :

Example 36 with QueryResult

use of io.trino.tempto.query.QueryResult in project trino by trinodb.

the class TestRoles method testListRoles.

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

Example 37 with QueryResult

use of io.trino.tempto.query.QueryResult in project trino by trinodb.

the class TestSyncPartitionMetadata method assertPartitions.

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

Example 38 with QueryResult

use of io.trino.tempto.query.QueryResult in project trino by trinodb.

the class TestSyncPartitionMetadata method assertData.

private static void assertData(String tableName, QueryAssert.Row... rows) {
    QueryResult dataResult = onTrino().executeQuery("SELECT payload, col_x, col_y FROM " + tableName + " ORDER BY 1, 2, 3 ASC");
    assertThat(dataResult).containsExactlyInOrder(rows);
}
Also used : QueryResult(io.trino.tempto.query.QueryResult)

Example 39 with QueryResult

use of io.trino.tempto.query.QueryResult in project trino by trinodb.

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 = onTrino().executeQuery(selectFromOnePartitionsSql);
    assertThat(onePartitionQueryResult).containsOnly(row(42, 2));
    try {
        // This query should fail or return null values for invalid partition data
        assertThat(onTrino().executeQuery("SELECT * FROM " + tableNameInDatabase)).containsOnly(row(42, 2), row(null, 1));
    } catch (QueryExecutionException expectedDueToInvalidPartitionData) {
    }
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) QueryExecutionException(io.trino.tempto.query.QueryExecutionException) ProductTest(io.trino.tempto.ProductTest) Test(org.testng.annotations.Test)

Example 40 with QueryResult

use of io.trino.tempto.query.QueryResult in project trino by trinodb.

the class TestKafkaAvroReadsSmokeTest method testNullType.

@Test(groups = { KAFKA, PROFILE_SPECIFIC_TESTS }, dataProvider = "catalogs")
public void testNullType(KafkaCatalog kafkaCatalog, MessageSerializer messageSerializer) throws Exception {
    String topicName = ALL_NULL_AVRO_TOPIC_NAME + kafkaCatalog.getTopicNameSuffix();
    createAvroTable(ALL_DATATYPE_SCHEMA_PATH, ALL_NULL_AVRO_TOPIC_NAME, topicName, ImmutableMap.of(), messageSerializer);
    assertEventually(new Duration(30, SECONDS), () -> {
        QueryResult queryResult = onTrino().executeQuery(format("select * from %s.%s", kafkaCatalog.getCatalogName(), KAFKA_SCHEMA + "." + topicName));
        assertThat(queryResult).containsOnly(row(null, null, null, null));
    });
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest)

Aggregations

QueryResult (io.trino.tempto.query.QueryResult)84 Test (org.testng.annotations.Test)75 ProductTest (io.trino.tempto.ProductTest)61 Requires (io.trino.tempto.Requires)16 Row (io.trino.tempto.assertions.QueryAssert.Row)8 BigDecimal (java.math.BigDecimal)8 Duration (io.airlift.units.Duration)7 Flaky (io.trino.testng.services.Flaky)6 Statement (java.sql.Statement)6 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 QueryExecutionException (io.trino.tempto.query.QueryExecutionException)4 PreparedStatement (java.sql.PreparedStatement)4 ImmutableList (com.google.common.collect.ImmutableList)3 Row.row (io.trino.tempto.assertions.QueryAssert.Row.row)3 QueryAssert.assertThat (io.trino.tempto.assertions.QueryAssert.assertThat)3 List (java.util.List)3 Inject (com.google.inject.Inject)2 HiveTimestampPrecision (io.trino.plugin.hive.HiveTimestampPrecision)2 HMS_ONLY (io.trino.tests.product.TestGroups.HMS_ONLY)2 STORAGE_FORMATS (io.trino.tests.product.TestGroups.STORAGE_FORMATS)2