Search in sources :

Example 11 with Requires

use of io.trino.tempto.Requires in project trino by trinodb.

the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesTextFile.

@Requires(TextRequirements.class)
@Test(groups = SMOKE)
public void testSelectAllDatatypesTextFile() {
    String tableName = ALL_HIVE_SIMPLE_TYPES_TEXTFILE.getName();
    assertProperAllDatatypesSchema(tableName);
    QueryResult queryResult = onTrino().executeQuery(format("SELECT * FROM %s", tableName));
    assertColumnTypes(queryResult);
    assertThat(queryResult).containsOnly(row(127, 32767, 2147483647, 9223372036854775807L, 123.345f, 234.567, new BigDecimal("346"), new BigDecimal("345.67800"), Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)), Date.valueOf("2015-05-10"), "ala ma kota", "ala ma kot", "ala ma    ", true, "kot binarny".getBytes(UTF_8)));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) BigDecimal(java.math.BigDecimal) Requires(io.trino.tempto.Requires) Test(org.testng.annotations.Test)

Example 12 with Requires

use of io.trino.tempto.Requires in project trino by trinodb.

the class TestJdbc method shouldInsertSelectQuery.

@Test(groups = JDBC)
@Requires(ImmutableAndMutableNationTable.class)
public void shouldInsertSelectQuery() throws SQLException {
    String tableNameInDatabase = mutableTablesState().get(TABLE_NAME).getNameInDatabase();
    assertThat(onTrino().executeQuery("SELECT * FROM " + tableNameInDatabase)).hasNoRows();
    try (Statement statement = connection().createStatement()) {
        assertThat(statement.executeUpdate("insert into " + tableNameInDatabase + " select * from nation")).isEqualTo(25);
    }
    assertThat(onTrino().executeQuery("SELECT * FROM " + tableNameInDatabase)).matches(PRESTO_NATION_RESULT);
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 13 with Requires

use of io.trino.tempto.Requires in project trino by trinodb.

the class TestJdbc method shouldExecuteQueryWithSelectedCatalogAndSchema.

@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldExecuteQueryWithSelectedCatalogAndSchema() throws SQLException {
    connection().setCatalog("hive");
    connection().setSchema("default");
    try (Statement statement = connection().createStatement()) {
        QueryResult result = queryResult(statement, "select * from nation");
        assertThat(result).matches(PRESTO_NATION_RESULT);
    }
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 14 with Requires

use of io.trino.tempto.Requires in project trino by trinodb.

the class TestJdbc method shouldGetTables.

@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldGetTables() throws SQLException {
    QueryResult result = QueryResult.forResultSet(metaData().getTables("hive", null, null, null));
    assertThat(result).contains(row("hive", "default", "nation", "TABLE", null, null, null, null, null, null));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 15 with Requires

use of io.trino.tempto.Requires in project trino by trinodb.

the class TestJdbc method shouldExecuteQuery.

@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldExecuteQuery() throws SQLException {
    try (Statement statement = connection().createStatement()) {
        QueryResult result = queryResult(statement, "select * from hive.default.nation");
        assertThat(result).matches(PRESTO_NATION_RESULT);
    }
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Aggregations

Requires (io.trino.tempto.Requires)18 Test (org.testng.annotations.Test)18 QueryResult (io.trino.tempto.query.QueryResult)16 ProductTest (io.trino.tempto.ProductTest)12 BigDecimal (java.math.BigDecimal)7 Statement (java.sql.Statement)6 PreparedStatement (java.sql.PreparedStatement)3 BigInteger (java.math.BigInteger)1