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 presto by prestodb.
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 presto by prestodb.
the class JdbcTests 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);
}
}
use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.
the class JdbcTests method shouldSetLocale.
@Test(groups = JDBC)
public void shouldSetLocale() throws SQLException {
if (usingPrestoJdbcDriver(connection())) {
((PrestoConnection) 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("一月"));
}
} else {
LOGGER.warn("shouldSetLocale() only applies to PrestoJdbcDriver");
}
}
Aggregations