Skip to content

Commit 773e182

Browse files
committed
fix(bigquery): reject incomplete job for Arrow query format with UnsupportedOperationException
1 parent 6a5ab01 commit 773e182

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
@@ -2526,13 +2526,10 @@ && getOptions().getOpenTelemetryTracer() != null) {
25262526
throw new BigQueryException(bigQueryErrors);
25272527
}
25282528

2529-
// If query is incomplete, fallback to fetching the Job.
2529+
// If query is incomplete, Arrow format for slow query path is not yet supported.
25302530
if (!Boolean.TRUE.equals(results.getJobComplete())) {
2531-
if (results.getJobReference() == null) {
2532-
throw new BigQueryException(0, "Job is incomplete, but no job reference was returned.");
2533-
}
2534-
JobId jobId = JobId.fromPb(results.getJobReference());
2535-
return getJob(jobId, options);
2531+
throw new UnsupportedOperationException(
2532+
"Arrow results format for slow query path execution is not yet supported.");
25362533
}
25372534

25382535
// 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)