Search in sources :

Example 26 with QueryResult

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

the class TestSelectMultiColumnKey method testSelectWithFilterOnSecondClusteringKey.

@Test(groups = { CASSANDRA, PROFILE_SPECIFIC_TESTS })
public void testSelectWithFilterOnSecondClusteringKey() {
    // Since update_at is the second clustering key, this forces a full table scan.
    String sql = format("SELECT value FROM %s.%s.%s WHERE user_id = 'Bob' and updated_at = TIMESTAMP '2014-02-02 03:04:05Z'", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_MULTI_COLUMN_KEY.getName());
    QueryResult queryResult = onTrino().executeQuery(sql);
    assertThat(queryResult).containsOnly(row("Test value 2"));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) ProductTest(io.trino.tempto.ProductTest) Test(org.testng.annotations.Test)

Example 27 with QueryResult

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

the class TestSelectMultiColumnKey method testSelectWithFilterOnPrimaryKeyNoMatch.

@Test(groups = { CASSANDRA, PROFILE_SPECIFIC_TESTS })
public void testSelectWithFilterOnPrimaryKeyNoMatch() {
    String sql = format("SELECT value FROM %s.%s.%s WHERE user_id = 'George'", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_MULTI_COLUMN_KEY.getName());
    QueryResult queryResult = onTrino().executeQuery(sql);
    assertThat(queryResult).hasNoRows();
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) ProductTest(io.trino.tempto.ProductTest) Test(org.testng.annotations.Test)

Example 28 with QueryResult

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

the class TestJdbc method assertConnectionTimezone.

private void assertConnectionTimezone(Connection connection, String timeZoneId) throws SQLException {
    try (Statement statement = connection.createStatement()) {
        QueryResult result = queryResult(statement, "select current_timezone()");
        assertThat(result).contains(row(timeZoneId));
    }
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement)

Example 29 with QueryResult

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

the class TestJdbc method shouldGetColumns.

@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldGetColumns() throws SQLException {
    QueryResult result = QueryResult.forResultSet(metaData().getColumns("hive", "default", "nation", null));
    assertThat(result).matches(sqlResultDescriptorForResource("io/trino/tests/product/jdbc/get_nation_columns.result"));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 30 with QueryResult

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

the class TestJdbc method shouldSetLocale.

@Test(groups = JDBC)
public void shouldSetLocale() throws SQLException {
    // TODO uew new connection rather than modifying a shared one
    ((TrinoConnection) connection()).setLocale(CHINESE);
    try (Statement statement = connection().createStatement()) {
        QueryResult result = queryResult(statement, "SELECT date_format(TIMESTAMP '2001-01-09 09:04', '%M')");
        assertThat(result).contains(row("一月"));
    }
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) TrinoConnection(io.trino.jdbc.TrinoConnection) 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