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");
}
}
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));
}
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()));
}
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);
}
Aggregations