use of io.trino.tempto.query.QueryResult in project trino by trinodb.
the class TestSelect method testSelectWithMorePartitioningKeysThanLimit.
@Test(groups = { CASSANDRA, PROFILE_SPECIFIC_TESTS })
public void testSelectWithMorePartitioningKeysThanLimit() {
String sql = format("SELECT s_suppkey FROM %s.%s.%s WHERE s_suppkey = 10", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_SUPPLIER.getName());
QueryResult queryResult = onTrino().executeQuery(sql);
assertThat(queryResult).containsOnly(row(10));
}
use of io.trino.tempto.query.QueryResult in project trino by trinodb.
the class TestSelect method testSelectWithEqualityFilterOnNonPartitioningKey.
@Test(groups = { CASSANDRA, PROFILE_SPECIFIC_TESTS })
public void testSelectWithEqualityFilterOnNonPartitioningKey() {
String sql = format("SELECT n_name FROM %s.%s.%s WHERE n_name = 'UNITED STATES'", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_NATION.getName());
QueryResult queryResult = onTrino().executeQuery(sql);
assertThat(queryResult).containsOnly(row("UNITED STATES"));
}
use of io.trino.tempto.query.QueryResult in project trino by trinodb.
the class TestSelect method testSelectWithEqualityFilterOnPartitioningKey.
@Test(groups = { CASSANDRA, PROFILE_SPECIFIC_TESTS })
public void testSelectWithEqualityFilterOnPartitioningKey() {
String sql = format("SELECT n_nationkey FROM %s.%s.%s WHERE n_nationkey = 0", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_NATION.getName());
QueryResult queryResult = onTrino().executeQuery(sql);
assertThat(queryResult).containsOnly(row(0));
}
use of io.trino.tempto.query.QueryResult in project trino by trinodb.
the class TestSelect method testSelectAllTypePartitioningMaterializedView.
@Test(groups = { CASSANDRA, PROFILE_SPECIFIC_TESTS })
public void testSelectAllTypePartitioningMaterializedView() {
String materializedViewName = format("%s_partitioned_mv", CASSANDRA_ALL_TYPES.getName());
onCassandra(format("DROP MATERIALIZED VIEW IF EXISTS %s.%s", KEY_SPACE, materializedViewName));
onCassandra(format("CREATE MATERIALIZED VIEW %s.%s AS SELECT * FROM %s.%s WHERE b IS NOT NULL PRIMARY KEY (a, b)", KEY_SPACE, materializedViewName, KEY_SPACE, CASSANDRA_ALL_TYPES.getName()));
assertContainsEventually(() -> onTrino().executeQuery(format("SHOW TABLES FROM %s.%s", CONNECTOR_NAME, KEY_SPACE)), onTrino().executeQuery(format("SELECT '%s'", materializedViewName)), new Duration(1, MINUTES));
// Materialized view may not return all results during the creation
assertContainsEventually(() -> onTrino().executeQuery(format("SELECT status_replicated FROM %s.system.built_views WHERE view_name = '%s'", CONNECTOR_NAME, materializedViewName)), onTrino().executeQuery("SELECT true"), new Duration(1, MINUTES));
QueryResult query = onTrino().executeQuery(format("SELECT a, b, bl, bo, d, do, dt, f, fr, i, integer, l, m, s, si, t, ti, ts, tu, u, v, vari FROM %s.%s.%s WHERE a = '\0'", CONNECTOR_NAME, KEY_SPACE, materializedViewName));
assertThat(query).hasColumns(VARCHAR, BIGINT, VARBINARY, BOOLEAN, DOUBLE, DOUBLE, DATE, REAL, VARCHAR, VARCHAR, INTEGER, VARCHAR, VARCHAR, VARCHAR, SMALLINT, VARCHAR, TINYINT, TIMESTAMP_WITH_TIMEZONE, JAVA_OBJECT, JAVA_OBJECT, VARCHAR, VARCHAR).containsOnly(row("\0", Long.MIN_VALUE, Bytes.fromHexString("0x00").array(), false, 0f, Double.MIN_VALUE, Date.valueOf("1970-01-02"), Float.MIN_VALUE, "[0]", "0.0.0.0", Integer.MIN_VALUE, "[0]", "{\"\\u0000\":-2147483648,\"a\":0}", "[0]", Short.MIN_VALUE, "\0", Byte.MIN_VALUE, Timestamp.from(OffsetDateTime.of(1970, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).toInstant()), "d2177dd0-eaa2-11de-a572-001b779c76e3", "01234567-0123-0123-0123-0123456789ab", "\0", String.valueOf(Long.MIN_VALUE)));
onCassandra(format("DROP MATERIALIZED VIEW IF EXISTS %s.%s", KEY_SPACE, materializedViewName));
}
use of io.trino.tempto.query.QueryResult in project trino by trinodb.
the class TestSelect method testSelectClusteringMaterializedView.
@Test(groups = { CASSANDRA, PROFILE_SPECIFIC_TESTS })
public void testSelectClusteringMaterializedView() {
String mvName = "clustering_mv";
onCassandra(format("DROP MATERIALIZED VIEW IF EXISTS %s.%s", KEY_SPACE, mvName));
onCassandra(format("CREATE MATERIALIZED VIEW %s.%s AS " + "SELECT * FROM %s.%s " + "WHERE s_nationkey IS NOT NULL " + "PRIMARY KEY (s_nationkey, s_suppkey) " + "WITH CLUSTERING ORDER BY (s_nationkey DESC)", KEY_SPACE, mvName, KEY_SPACE, CASSANDRA_SUPPLIER.getName()));
assertContainsEventually(() -> onTrino().executeQuery(format("SHOW TABLES FROM %s.%s", CONNECTOR_NAME, KEY_SPACE)), onTrino().executeQuery(format("SELECT '%s'", mvName)), new Duration(1, MINUTES));
// Materialized view may not return all results during the creation
assertContainsEventually(() -> onTrino().executeQuery(format("SELECT status_replicated FROM %s.system.built_views WHERE view_name = '%s'", CONNECTOR_NAME, mvName)), onTrino().executeQuery("SELECT true"), new Duration(1, MINUTES));
QueryResult aggregateQueryResult = onTrino().executeQuery(format("SELECT MAX(s_nationkey), SUM(s_suppkey), AVG(s_acctbal) " + "FROM %s.%s.%s WHERE s_suppkey BETWEEN 1 AND 10 ", CONNECTOR_NAME, KEY_SPACE, mvName));
assertThat(aggregateQueryResult).containsOnly(row(24, 55, 4334.653));
QueryResult orderedResult = onTrino().executeQuery(format("SELECT s_nationkey, s_suppkey, s_acctbal " + "FROM %s.%s.%s WHERE s_nationkey = 1 LIMIT 1", CONNECTOR_NAME, KEY_SPACE, mvName));
assertThat(orderedResult).containsOnly(row(1, 3, 4192.4));
onCassandra(format("DROP MATERIALIZED VIEW IF EXISTS %s.%s", KEY_SPACE, mvName));
}
Aggregations