use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.
the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesOrc.
@Requires(OrcRequirements.class)
@Test(groups = { JDBC })
public void testSelectAllDatatypesOrc() {
String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_ORC).getNameInDatabase();
populateDataToHiveTable(tableName);
assertProperAllDatatypesSchema(tableName);
QueryResult queryResult = query(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()));
}
use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.
the class SqlCancelTests method cancelQuery.
private void cancelQuery(String sql) throws InterruptedException {
Stopwatch stopwatch = Stopwatch.createStarted();
while (stopwatch.elapsed(SECONDS) < 30) {
String findQuerySql = "SELECT query_id from system.runtime.queries WHERE query = '%s' and state = 'RUNNING' LIMIT 2";
QueryResult queryResult = query(format(findQuerySql, sql));
checkState(queryResult.getRowsCount() < 2, "Query is executed multiple times");
if (queryResult.getRowsCount() == 1) {
String queryId = (String) queryResult.row(0).get(0);
Response response = queryCanceller.cancel(queryId);
Assertions.assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT.code());
return;
}
MILLISECONDS.sleep(100L);
}
throw new IllegalStateException("Query did not reach running state or maybe it was too quick.");
}
use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.
the class BlackHoleConnector method blackHoleConnector.
@Test(groups = { BLACKHOLE_CONNECTOR })
public void blackHoleConnector() {
String nullTable = "\"blackhole\".default.nation_" + UUID.randomUUID().toString().replace("-", "");
String table = "tpch.tiny.nation";
assertThat(query(format("SELECT count(*) from %s", table))).containsExactly(row(25));
QueryResult result = query(format("CREATE TABLE %s AS SELECT * FROM %s", nullTable, table));
try {
assertThat(result).updatedRowsCountIsEqualTo(25);
assertThat(query(format("INSERT INTO %s SELECT * FROM %s", nullTable, table))).updatedRowsCountIsEqualTo(25);
assertThat(query(format("SELECT * FROM %s", nullTable))).hasNoRows();
} finally {
query(format("DROP TABLE %s", nullTable));
}
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class JdbcTests 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));
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class PreparedStatements method preparedInsertVarbinarySql.
@Test(groups = { JDBC, SIMBA_JDBC })
@Requires(MutableAllTypesTable.class)
public void preparedInsertVarbinarySql() throws SQLException {
if (usingTeradataJdbcDriver(connection())) {
String tableNameInDatabase = mutableTablesState().get(TABLE_NAME_MUTABLE).getNameInDatabase();
String insertSqlWithTable = "PREPARE ps1 from " + String.format(INSERT_SQL, tableNameInDatabase);
String selectSqlWithTable = String.format(SELECT_STAR_SQL, tableNameInDatabase);
String executeSql = "EXECUTE ps1 using ";
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 = query(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 }));
} else {
LOGGER.warn("preparedInsertVarbinarySql() only applies to TeradataJdbcDriver");
}
}
Aggregations