QueryResponse executeQuickQuery(Jobs jobs, String projectid, String query) throws IOException {
long starttime = System.nanoTime();
QueryRequest queryrequest = new QueryRequest().setQuery(query);
QueryResponse queryresponse = jobs.query(projectid, queryrequest).execute();
TableSchema schema = queryresponse.getSchema();
log.info("Table schema: " + schema.toPrettyString());
List<TableFieldSchema> fields = schema.getFields();
for (TableFieldSchema field : fields) {
String name = field.getName();
String type = field.getType();
String mode = field.getMode();
log.info("Field name: " + name + " type: " + " mode: " + mode);
}
BigInteger numberrows = queryresponse.getTotalRows();
log.info("Total rows: " + numberrows);
String pagetoken = queryresponse.getPageToken();
log.info("Page token: " + pagetoken);
String jobid = queryresponse.getJobReference().getJobId();
GetQueryResultsResponse results = jobs.getQueryResults(projectid, jobid).execute();
long endtime = 0;
if (results.getJobComplete()) {
endtime = System.nanoTime();
List<TableRow> rows = results.getRows();