KEMBAR78
Read API throws NPE for empty tables · Issue #3626 · googleapis/java-bigquery · GitHub
Skip to content

Read API throws NPE for empty tables #3626

@o-shevchenko

Description

@o-shevchenko

We get NPE when we read an empty table using Read API.
NPE happens here:

cursor = buffer.take(); // advance the cursor,Potentially blocking operation

When we run query Using Fast Query Path (Read API disabled) such code works fine.buffer.take() returns cursor and it correctly indicated in isEndOfStream as EndOfFieldValueList.
But when we enable Read API buffer.take() throws NPE since buffer is null.

Environment details

com.google.cloud:google-cloud-bigquery:2.45.0
Mac OS Sonoma M1
Java version: 17

Steps to reproduce

  1. Enable Read API (make sure you see Not Using Fast Query Path, using jobs.insert, see related issue I've attached)
  2. Read the empty table
  3. Execute next()

Code example

val connectionSettings = ConnectionSettings.newBuilder()
                    .setJobTimeoutMs(Long.MAX_VALUE) // that is crucial to enable Read API, see the attached issue
                    .setRequestTimeout(DEFAULT_QUERY_TIMEOUT_MS)
                    .setUseReadAPI(true)
                    .setMaxResults(DEFAULT_MAX_RESULT)
                    .setUseQueryCache(true)
                    .build()
                val connection = context.createConnection(connectionSettings)
                val bqResult = connection.executeSelect(code)
                bqResult.resultSet.next() // NPE
                

Stack trace

 onError(java.lang.NullPointerException: Cannot invoke "java.util.concurrent.BlockingQueue.take()" because the return value of "com.google.cloud.bigquery.BigQueryResultImpl.access$200(com.google.cloud.bigquery.BigQueryResultImpl)" is null))
 at com.google.cloud.bigquery.BigQueryResultImpl$BigQueryResultSet.next(BigQueryResultImpl.java:120)

Related issue: googleapis/java-bigquerystorage#2764
#3624

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/java-bigquery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions