use of io.prestosql.client.StatementClient in project hetu-core by openlookeng.
the class TestFinalQueryInfo method startQuery.
private static QueryId startQuery(String sql, DistributedQueryRunner queryRunner) {
OkHttpClient httpClient = new OkHttpClient();
try {
ClientSession clientSession = new ClientSession(queryRunner.getCoordinator().getBaseUrl(), "user", "source", Optional.empty(), ImmutableSet.of(), null, null, null, null, ZoneId.of("America/Los_Angeles"), Locale.ENGLISH, ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), null, new Duration(2, MINUTES));
// start query
StatementClient client = newStatementClient(httpClient, clientSession, sql);
// wait for query to be fully scheduled
while (client.isRunning() && !client.currentStatusInfo().getStats().isScheduled()) {
client.advance();
}
return new QueryId(client.currentStatusInfo().getId());
} finally {
// close the client since, query is not managed by the client protocol
httpClient.dispatcher().executorService().shutdown();
httpClient.connectionPool().evictAll();
}
}
Aggregations