use of io.trino.tempto.Requires in project trino by trinodb.
the class TestJdbc method shouldGetTableTypes.
@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldGetTableTypes() throws SQLException {
QueryResult result = QueryResult.forResultSet(metaData().getTableTypes());
assertThat(result).contains(row("TABLE"), row("VIEW"));
}
use of io.trino.tempto.Requires in project trino by trinodb.
the class TestPreparedStatements method preparedInsertSql.
@Test(groups = JDBC)
@Requires(MutableAllTypesTable.class)
public void preparedInsertSql() 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 + "cast(127 as tinyint), " + "cast(32767 as smallint), " + "2147483647, " + "9223372036854775807, " + "cast(123.345 as real), " + "cast(234.567 as double), " + "cast(345 as decimal(10)), " + "cast(345.678 as decimal(10,5)), " + "timestamp '2015-05-10 12:15:35', " + "date '2015-05-10', " + "'ala ma kota', " + "'ala ma kot', " + "cast('ala ma' as char(10)), " + "true, " + "X'00010203002AF9'");
statement.execute(executeSql + "cast(1 as tinyint), " + "cast(2 as smallint), " + "3, " + "4, " + "cast(5.6 as real), " + "cast(7.8 as double), " + "cast(9 as decimal(10)), " + "cast(2.3 as decimal(10,5)), " + "timestamp '2012-05-10 1:35:15', " + "date '2014-03-10', " + "'abc', " + "'def', " + "cast('ghi' as char(10)), " + "false, " + "varbinary 'jkl'");
statement.execute(executeSql + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "null, " + "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, 4, Float.valueOf("5.6"), 7.8, BigDecimal.valueOf(9), new BigDecimal("2.30000"), Timestamp.valueOf("2012-05-10 1:35:15"), Date.valueOf("2014-03-10"), "abc", "def", "ghi ", Boolean.FALSE, "jkl".getBytes(UTF_8)), row(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null));
}
}
use of io.trino.tempto.Requires in project trino by trinodb.
the class TestPreparedStatements method preparedSelectSql.
@Test(groups = JDBC)
@Requires(ImmutableAllTypesTable.class)
public void preparedSelectSql() throws SQLException {
String prepareSql = "PREPARE ps1 from SELECT c_int FROM " + TABLE_NAME + " WHERE c_int = ?";
final int testValue = 2147483647;
String executeSql = "EXECUTE ps1 using ";
try (Statement statement = connection().createStatement()) {
statement.execute(prepareSql);
assertThat(QueryResult.forResultSet(statement.executeQuery(executeSql + testValue))).containsOnly(row(testValue));
assertThat(QueryResult.forResultSet(statement.executeQuery(executeSql + "NULL"))).hasNoRows();
assertThat(QueryResult.forResultSet(statement.executeQuery(executeSql + 2))).hasNoRows();
}
}
Aggregations