Search in sources :

Example 81 with QueryResult

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

the class TestPhoenix method testCreateTableAsSelect.

@Test(groups = { PHOENIX, PROFILE_SPECIFIC_TESTS })
public void testCreateTableAsSelect() {
    QueryResult result = onTrino().executeQuery("CREATE TABLE nation AS SELECT * FROM tpch.tiny.nation");
    try {
        assertThat(result).updatedRowsCountIsEqualTo(25);
        assertThat(onTrino().executeQuery("SELECT COUNT(*) FROM nation")).containsOnly(row(25));
    } finally {
        onTrino().executeQuery("DROP TABLE nation");
    }
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) ProductTest(io.trino.tempto.ProductTest) Test(org.testng.annotations.Test)

Example 82 with QueryResult

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

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 = onTrino().executeQuery(sql);
    assertThat(queryResult).containsOnly(row("CANADA", 3), row("CANADA", 3), row("CANADA", 3), row("CANADA", 3), row("CANADA", 3));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest)

Example 83 with QueryResult

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

the class TestSelect method testAllDatatypes.

@Test(groups = { SQL_SERVER, PROFILE_SPECIFIC_TESTS })
public void testAllDatatypes() {
    QueryResult queryResult = onTrino().executeQuery("SELECT * FROM " + ALL_TYPES_TABLE_NAME);
    assertThat(queryResult).hasColumns(BIGINT, SMALLINT, INTEGER, SMALLINT, DOUBLE, REAL, CHAR, VARCHAR, VARCHAR, CHAR, VARCHAR, VARCHAR, DATE, TIMESTAMP, TIMESTAMP, TIMESTAMP, TIMESTAMP, DOUBLE, REAL).containsOnly(row(Long.MIN_VALUE, Short.MIN_VALUE, Integer.MIN_VALUE, 0, Double.MIN_VALUE, -3.40E+38f, "\0   ", "\0", "\0", "\0    ", "\0", "\0", Date.valueOf("1953-01-02"), Timestamp.valueOf("1953-01-01 00:00:00.000"), Timestamp.valueOf("2001-01-01 00:00:00.123"), Timestamp.valueOf("1970-01-01 00:00:00.000"), Timestamp.valueOf("1960-01-01 00:00:00"), Double.MIN_VALUE, -3.40E+38f), row(Long.MAX_VALUE, Short.MAX_VALUE, Integer.MAX_VALUE, 255, 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("9999-12-31 23:59:59.999"), Timestamp.valueOf("2079-06-06 00:00:00"), 12345678912.3456756, 12345678.6557f), row(nCopies(19, null).toArray()));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest)

Example 84 with QueryResult

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

the class CachingTestUtils method getCacheStats.

public static CacheStats getCacheStats() {
    QueryResult queryResult = onTrino().executeQuery("SELECT " + "  sum(Cached_rrc_requests) as cachedreads, " + "  sum(Remote_rrc_requests + Direct_rrc_requests) as remotereads, " + "  sum(Nonlocal_rrc_requests) as nonlocalreads " + "FROM jmx.current.\"rubix:catalog=hive,type=detailed,name=stats\";");
    long cachedReads = (Long) getOnlyElement(queryResult.rows()).get(queryResult.tryFindColumnIndex("cachedreads").get() - 1);
    long remoteReads = (Long) getOnlyElement(queryResult.rows()).get(queryResult.tryFindColumnIndex("remotereads").get() - 1);
    long nonLocalReads = (Long) getOnlyElement(queryResult.rows()).get(queryResult.tryFindColumnIndex("nonlocalreads").get() - 1);
    long asyncDownloadedMb = (Long) getOnlyElement(onTrino().executeQuery("SELECT sum(Count) FROM " + "jmx.current.\"metrics:name=rubix.bookkeeper.count.async_downloaded_mb\"").rows()).get(0);
    return new CacheStats(cachedReads, remoteReads, nonLocalReads, asyncDownloadedMb);
}
Also used : QueryResult(io.trino.tempto.query.QueryResult)

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