Search in sources :

Example 16 with QueryResult

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));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest)

Example 17 with QueryResult

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"));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest)

Example 18 with QueryResult

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));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest)

Example 19 with QueryResult

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));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest)

Example 20 with QueryResult

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));
}
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