Skip to content

Commit b3edf0a

Browse files
committed
fix(bigquery): reject incomplete job for Arrow query format with UnsupportedOperationException
1 parent 88c9eb9 commit b3edf0a

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,13 +2498,10 @@ && getOptions().getOpenTelemetryTracer() != null) {
24982498
throw new BigQueryException(bigQueryErrors);
24992499
}
25002500

2501-
// If query is incomplete, fallback to fetching the Job.
2501+
// If query is incomplete, Arrow format for slow query path is not yet supported.
25022502
if (!Boolean.TRUE.equals(results.getJobComplete())) {
2503-
if (results.getJobReference() == null) {
2504-
throw new BigQueryException(0, "Job is incomplete, but no job reference was returned.");
2505-
}
2506-
JobId jobId = JobId.fromPb(results.getJobReference());
2507-
return getJob(jobId, options);
2503+
throw new UnsupportedOperationException(
2504+
"Arrow results format for slow query path execution is not yet supported.");
25082505
}
25092506

25102507
// If query is complete but Arrow schema is missing or invalid, fallback to standard JSON

‎java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,6 +3287,31 @@ void testQueryWithArrowFormatMissingSerializedSchema() throws Exception {
32873287
assertTrue(e.getMessage().contains("Arrow schema is missing from the response"));
32883288
}
32893289

3290+
@Test
3291+
void testQueryWithArrowFormatIncompleteJob() throws Exception {
3292+
JobId queryJob = JobId.of(PROJECT, JOB).toBuilder().setLocation(LOCATION).build();
3293+
com.google.api.services.bigquery.model.QueryResponse queryResponsePb =
3294+
new com.google.api.services.bigquery.model.QueryResponse()
3295+
.setQueryId("q-arrow-incomplete")
3296+
.setJobComplete(false)
3297+
.setJobReference(queryJob.toPb());
3298+
3299+
when(bigqueryRpcMock.queryRpcSkipExceptionTranslation(eq(PROJECT), any(QueryRequest.class)))
3300+
.thenReturn(queryResponsePb);
3301+
3302+
bigquery = options.getService();
3303+
3304+
QueryJobConfiguration config =
3305+
QueryJobConfiguration.newBuilder("SELECT id FROM test")
3306+
.setQueryResultsFormat(QueryResultsFormat.ARROW)
3307+
.build();
3308+
UnsupportedOperationException e =
3309+
assertThrows(UnsupportedOperationException.class, () -> bigquery.query(config));
3310+
assertTrue(
3311+
e.getMessage()
3312+
.contains("Arrow results format for slow query path execution is not yet supported."));
3313+
}
3314+
32903315
@Test
32913316
void testGetQueryResults() throws IOException {
32923317
JobId queryJob = JobId.of(JOB);

0 commit comments

Comments
 (0)