From 251d4686d22e0000982bcd891de68491326558fe Mon Sep 17 00:00:00 2001 From: Prashant Mishra <11733935+prash-mi@users.noreply.github.com> Date: Wed, 18 May 2022 21:06:12 +0530 Subject: [PATCH] fix: NPE issue with testMultipleRuns (#2050) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a `null` check for `firstPage.getSchema()` as we might get null schema when the job is long running (We get schema using dryRun in such cases) Fixes #2049 ☕️ --- .../main/java/com/google/cloud/bigquery/ConnectionImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java index b43615141..cc330a90a 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java @@ -234,8 +234,10 @@ public BigQueryResult executeSelect( BigQueryResult getResultSet( GetQueryResultsResponse firstPage, JobId jobId, String sql, Boolean hasQueryParameters) { if (firstPage.getJobComplete() - && firstPage.getTotalRows() - != null) { // firstPage.getTotalRows() is null if job is not complete + && firstPage.getTotalRows() != null + && firstPage.getSchema() + != null) { // firstPage.getTotalRows() is null if job is not complete. We need to make + // sure that the schema is not null, as it is required for the ResultSet return getSubsequentQueryResultsWithJob( firstPage.getTotalRows().longValue(), (long) firstPage.getRows().size(),