fix: NPE when reading BigQueryResultSet from empty tables by PhongChuong · Pull Request #3627 · googleapis/java-bigquery · GitHub
Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ ListenableFuture<ExecuteSelectResponse> executeSelectAsync(String sql)
* &#64;code
* ConnectionSettings connectionSettings =
* ConnectionSettings.newBuilder()
* ..setUseReadAPI(true)
* .setUseReadAPI(true)
* .build();
* Connection connection = bigquery.createConnection(connectionSettings);
* String selectQuery =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public void testLegacyQuerySinglePage() throws BigQuerySQLException {

// calls executeSelect with a nonFast query where the query returns an empty result.
@Test
public void testLegacyQuerySinglePageEmptyResults() throws BigQuerySQLException {
public void testLegacyQuerySinglePageEmptyResults() throws BigQuerySQLException, SQLException {
ConnectionImpl connectionSpy = Mockito.spy(connection);
com.google.api.services.bigquery.model.Job jobResponseMock =
new com.google.api.services.bigquery.model.Job()
Expand All @@ -428,6 +428,10 @@ public void testLegacyQuerySinglePageEmptyResults() throws BigQuerySQLException
BigQueryResult res = connectionSpy.executeSelect(SQL_QUERY);
assertEquals(res.getTotalRows(), 0);
assertEquals(QUERY_SCHEMA, res.getSchema());
assertEquals(
false,
res.getResultSet()
.next()); // Validates that NPE does not occur when reading from empty ResultSet.
verify(bigqueryRpcMock, times(1))
.createJobForQuery(any(com.google.api.services.bigquery.model.Job.class));
}
Expand Down