Search in sources :

Example 6 with Requires

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

the class TestPreparedStatements method preparedInsertVarbinaryApi.

@Test(groups = JDBC)
@Requires(MutableAllTypesTable.class)
public void preparedInsertVarbinaryApi() {
    String tableNameInDatabase = mutableTablesState().get(TABLE_NAME_MUTABLE).getNameInDatabase();
    String insertSqlWithTable = format(INSERT_SQL, tableNameInDatabase);
    String selectSqlWithTable = format(SELECT_STAR_SQL, tableNameInDatabase);
    onTrino().executeQuery(insertSqlWithTable, param(TINYINT, null), param(SMALLINT, null), param(INTEGER, null), param(BIGINT, null), param(FLOAT, null), param(DOUBLE, null), param(DECIMAL, null), param(DECIMAL, null), param(TIMESTAMP, null), param(DATE, null), param(VARCHAR, null), param(VARCHAR, null), param(CHAR, null), param(BOOLEAN, null), param(VARBINARY, new byte[] { 0, 1, 2, 3, 0, 42, -7 }));
    QueryResult result = onTrino().executeQuery(selectSqlWithTable);
    assertColumnTypes(result);
    assertThat(result).containsOnly(row(null, null, null, null, null, null, null, null, null, null, null, null, null, null, new byte[] { 0, 1, 2, 3, 0, 42, -7 }));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 7 with Requires

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

the class TestPreparedStatements method preparedInsertApi.

@Test(groups = JDBC)
@Requires(MutableAllTypesTable.class)
public void preparedInsertApi() {
    String tableNameInDatabase = mutableTablesState().get(TABLE_NAME_MUTABLE).getNameInDatabase();
    String insertSqlWithTable = format(INSERT_SQL, tableNameInDatabase);
    String selectSqlWithTable = format(SELECT_STAR_SQL, tableNameInDatabase);
    onTrino().executeQuery(insertSqlWithTable, param(TINYINT, 127), param(SMALLINT, 32767), param(INTEGER, 2147483647), param(BIGINT, new BigInteger("9223372036854775807")), param(FLOAT, Float.valueOf("123.345")), param(DOUBLE, 234.567), param(DECIMAL, BigDecimal.valueOf(345)), param(DECIMAL, BigDecimal.valueOf(345.678)), param(TIMESTAMP, Timestamp.valueOf("2015-05-10 12:15:35")), param(DATE, Date.valueOf("2015-05-10")), param(VARCHAR, "ala ma kota"), param(VARCHAR, "ala ma kot"), param(CHAR, "    ala ma"), param(BOOLEAN, Boolean.TRUE), param(VARBINARY, new byte[] { 0, 1, 2, 3, 0, 42, -7 }));
    onTrino().executeQuery(insertSqlWithTable, param(TINYINT, 1), param(SMALLINT, 2), param(INTEGER, 3), param(BIGINT, 4), param(FLOAT, Float.valueOf("5.6")), param(DOUBLE, 7.8), param(DECIMAL, BigDecimal.valueOf(91)), param(DECIMAL, BigDecimal.valueOf(2.3)), param(TIMESTAMP, Timestamp.valueOf("2012-05-10 1:35:15")), param(DATE, Date.valueOf("2014-03-10")), param(VARCHAR, "abc"), param(VARCHAR, "def"), param(CHAR, "       ghi"), param(BOOLEAN, Boolean.FALSE), param(VARBINARY, new byte[] { 0, 1, 2, 3, 0, 42, -7 }));
    onTrino().executeQuery(insertSqlWithTable, param(TINYINT, null), param(SMALLINT, null), param(INTEGER, null), param(BIGINT, null), param(FLOAT, null), param(DOUBLE, null), param(DECIMAL, null), param(DECIMAL, null), param(TIMESTAMP, null), param(DATE, null), param(VARCHAR, null), param(VARCHAR, null), param(CHAR, null), param(BOOLEAN, null), param(VARBINARY, null));
    QueryResult result = onTrino().executeQuery(selectSqlWithTable);
    assertColumnTypes(result);
    assertThat(result).containsOnly(row(127, 32767, 2147483647, Long.valueOf("9223372036854775807"), Float.valueOf("123.345"), 234.567, BigDecimal.valueOf(345), new BigDecimal("345.67800"), Timestamp.valueOf("2015-05-10 12:15:35"), Date.valueOf("2015-05-10"), "ala ma kota", "ala ma kot", "    ala ma", Boolean.TRUE, new byte[] { 0, 1, 2, 3, 0, 42, -7 }), row(1, 2, 3, 4L, Float.valueOf("5.6"), 7.8, BigDecimal.valueOf(91), BigDecimal.valueOf(2.3), Timestamp.valueOf("2012-05-10 1:35:15"), Date.valueOf("2014-03-10"), "abc", "def", "       ghi", Boolean.FALSE, new byte[] { 0, 1, 2, 3, 0, 42, -7 }), row(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) BigInteger(java.math.BigInteger) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 8 with Requires

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

the class TestPreparedStatements method preparedInsertVarbinarySql.

@Test(groups = JDBC)
@Requires(MutableAllTypesTable.class)
public void preparedInsertVarbinarySql() throws SQLException {
    String tableNameInDatabase = mutableTablesState().get(TABLE_NAME_MUTABLE).getNameInDatabase();
    String insertSqlWithTable = "PREPARE ps1 from " + format(INSERT_SQL, tableNameInDatabase);
    String selectSqlWithTable = format(SELECT_STAR_SQL, tableNameInDatabase);
    String executeSql = "EXECUTE ps1 using ";
    try (Statement statement = connection().createStatement()) {
        statement.execute(insertSqlWithTable);
        statement.execute(executeSql + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "X'00010203002AF9'");
        QueryResult result = onTrino().executeQuery(selectSqlWithTable);
        assertColumnTypes(result);
        assertThat(result).containsOnly(row(null, null, null, null, null, null, null, null, null, null, null, null, null, null, new byte[] { 0, 1, 2, 3, 0, 42, -7 }));
    }
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Statement(java.sql.Statement) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 9 with Requires

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

the class TestKafkaReadsSmokeTest method testSelectSimpleKeyAndValue.

@Test(groups = { KAFKA, PROFILE_SPECIFIC_TESTS })
@Requires(SimpleKeyAndValueTable.class)
public void testSelectSimpleKeyAndValue() {
    QueryResult queryResult = onTrino().executeQuery(format("select varchar_key, bigint_key, varchar_value, bigint_value from %s.%s.%s", KAFKA_CATALOG, SCHEMA_NAME, SIMPLE_KEY_AND_VALUE_TABLE_NAME));
    assertThat(queryResult).containsOnly(row("jasio", 1, "ania", 2), row("piotr", 3, "kasia", 4));
}
Also used : QueryResult(io.trino.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.trino.tempto.ProductTest) Requires(io.trino.tempto.Requires)

Example 10 with Requires

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

the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesParquetFile.

@Requires(ParquetRequirements.class)
@Test
public void testSelectAllDatatypesParquetFile() {
    String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_PARQUET).getNameInDatabase();
    onHive().executeQuery(format("INSERT INTO %s VALUES(" + "127," + "32767," + "2147483647," + "9223372036854775807," + "123.345," + "234.567," + "346," + "345.67800," + "'" + Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)).toString() + "'," + "'ala ma kota'," + "'ala ma kot'," + "'ala ma    '," + "true," + "'kot binarny'" + ")", tableName));
    assertThat(onTrino().executeQuery(format("SHOW COLUMNS FROM %s", tableName)).project(1, 2)).containsExactlyInOrder(row("c_tinyint", "tinyint"), row("c_smallint", "smallint"), row("c_int", "integer"), row("c_bigint", "bigint"), row("c_float", "real"), row("c_double", "double"), row("c_decimal", "decimal(10,0)"), row("c_decimal_w_params", "decimal(10,5)"), row("c_timestamp", "timestamp(3)"), row("c_string", "varchar"), row("c_varchar", "varchar(10)"), row("c_char", "char(10)"), row("c_boolean", "boolean"), row("c_binary", "varbinary"));
    QueryResult queryResult = onTrino().executeQuery(format("SELECT * FROM %s", tableName));
    assertColumnTypesParquet(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)), "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)

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