use of com.google.api.services.bigquery.model.QueryResponse in project beam by apache.
the class BigqueryMatcherTest method createResponseContainingTestData.
private QueryResponse createResponseContainingTestData() {
TableCell field1 = new TableCell();
field1.setV("abc");
TableCell field2 = new TableCell();
field2.setV("2");
TableCell field3 = new TableCell();
field3.setV("testing BigQuery matcher.");
TableRow row = new TableRow();
row.setF(Lists.newArrayList(field1, field2, field3));
QueryResponse response = new QueryResponse();
response.setJobComplete(true);
response.setRows(Lists.newArrayList(row));
response.setTotalRows(BigInteger.ONE);
return response;
}
use of com.google.api.services.bigquery.model.QueryResponse in project zeppelin by apache.
the class BigQueryInterpreter method run.
//Function to run the SQL on bigQuery service
public static Iterator<GetQueryResultsResponse> run(final String queryString, final String projId, final long wTime, final long maxRows) throws IOException {
try {
QueryResponse query = service.jobs().query(projId, new QueryRequest().setTimeoutMs(wTime).setQuery(queryString).setMaxResults(maxRows)).execute();
jobId = query.getJobReference().getJobId();
projectId = query.getJobReference().getProjectId();
GetQueryResults getRequest = service.jobs().getQueryResults(projectId, jobId);
return getPages(getRequest);
} catch (IOException ex) {
throw ex;
}
}
use of com.google.api.services.bigquery.model.QueryResponse in project beam by apache.
the class BigqueryMatcherTest method testBigqueryMatcherFailsWhenQueryJobNotComplete.
@Test
public void testBigqueryMatcherFailsWhenQueryJobNotComplete() throws Exception {
BigqueryMatcher matcher = spy(new BigqueryMatcher(appName, projectId, query, "some-checksum"));
doReturn(mockBigqueryClient).when(matcher).newBigqueryClient(anyString());
when(mockQuery.execute()).thenReturn(new QueryResponse().setJobComplete(false));
thrown.expect(AssertionError.class);
thrown.expectMessage("The query job hasn't completed.");
thrown.expectMessage("jobComplete=false");
try {
assertThat(mockResult, matcher);
} finally {
verify(matcher).newBigqueryClient(eq(appName));
verify(mockJobs).query(eq(projectId), eq(new QueryRequest().setQuery(query)));
}
}
Aggregations