-
Notifications
You must be signed in to change notification settings - Fork 130
Closed
Labels
api: bigqueryIssues related to the googleapis/java-bigquery API.Issues related to the googleapis/java-bigquery API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Thanks for stopping by to let us know something could be better!
Environment details
- Specify the API at the beginning of the title. For example, "BigQuery: ...").
General, Core, and Other are also allowed as types: Bigquery Java Client - OS type and version:
- Java version: 17 adoptium
- version(s): 2.19.2 and 2.20.0
Steps to reproduce
- set setUseReadAPI(false) on ConnectionSettings before building a connection
- run a query that takes more than 10 seconds using the
com.google.cloud.bigquery.Connectionquery APIs.
Sample Code
Standard usage with query that takes longer than 10 seconds (falls out of the fast query path).
ConnectionSettings connectionSettings =
ConnectionSettings.newBuilder()
.setUseReadAPI(false)
.setRequestTimeout(10L)
.setMaxResults(100L)
.setUseQueryCache(true)
.build();
Connection connection = bigquery.createConnection(connectionSettings);
String selectQuery = "<query that takes a little while and moves past the initial jobs.query timeout";
ListenableFuture<ExecuteSelectResponse> executeSelectFuture = connection.executeSelectAsync(selectQuery, ...);
Stack trace
java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because "totalRows" is null
at com.google.cloud.bigquery.ConnectionImpl.useReadAPI(ConnectionImpl.java:1220)
at com.google.cloud.bigquery.ConnectionImpl.getSubsequentQueryResultsWithJob(ConnectionImpl.java:844)
at com.google.cloud.bigquery.ConnectionImpl.queryRpc(ConnectionImpl.java:486)
at com.google.cloud.bigquery.ConnectionImpl.getExecuteSelectResponse(ConnectionImpl.java:236)
at com.google.cloud.bigquery.ConnectionImpl.executeSelect(ConnectionImpl.java:218)
at com.google.cloud.bigquery.ConnectionImpl.lambda$getExecuteSelectFuture$0(ConnectionImpl.java:305)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
... 3 more
Any additional information below
Looks like the exception is being thrown here: https://github.com/googleapis/java-bigquery/blob/v2.21.0/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java#L1220
Moving that check inside the if statement below it (which I think should be safe because of the check at the beginning of the method for null AND readAPI = true) should fix it.
Following these steps guarantees the quickest resolution possible.
Thanks!
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the googleapis/java-bigquery API.Issues related to the googleapis/java-bigquery API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.