googleapis / java-bigquery

Apache License 2.0
108 stars 119 forks source link

BigQuery connection api with fast path disabled throws NPE for queries that return 0 rows #3441

Closed dspangen closed 2 weeks ago

dspangen commented 3 weeks ago

Environment details

  1. Specify the API at the beginning of the title. For example, "BigQuery: ..."). General, Core, and Other are also allowed as types
  2. OS type and version: MacOS
  3. Java version: Temurin-21
  4. version(s): 2.42.0

Steps to reproduce

  1. You must use the connection api and ensure the fast path is disabled (setting a job timeout will ensure this)
  2. Your query must return no rows

Code example

bigQuery.createConnection(ConnectionSettings.newBuilder()
                        .setUseReadAPI(false)
                        .setJobTimeoutMs(10_000).build()).executeSelect("select * from (select 'blah' as col) where 1 = 0")

Relevant Stack trace

java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because the return value of "com.google.api.services.bigquery.model.GetQueryResultsResponse.getRows()" is null
    at com.google.cloud.bigquery.ConnectionImpl.getResultSet(ConnectionImpl.java:423)
    at com.google.cloud.bigquery.ConnectionImpl.getExecuteSelectResponse(ConnectionImpl.java:247)
    at com.google.cloud.bigquery.ConnectionImpl.executeSelect(ConnectionImpl.java:198)
        .... user code ....

External references such as API reference guides

Any additional information below

Following these steps guarantees the quickest resolution possible.

Thanks!

PhongChuong commented 2 weeks ago

Thank you for reporting the bug. It should be fixed in the next release.