Skip to content

Stateless queries fail with 404 when results require pagination #9168

@Pfaufisch

Description

@Pfaufisch

Stateless queries introduced in #9022 create QueryResults with an empty job ID when jobComplete is true (ref). When the result set spans multiple pages, rows() calls getQueryResults using that empty job ID, producing a 404:

 GET /bigquery/v2/projects/{project}/queries/?pageToken=...
                                            ^ missing job ID

Steps to reproduce

 $bq = new BigQueryClient(['keyFilePath' => '...']);
 $job = $bq->query('SELECT * FROM `dataset.large_table`'); // >10k rows
 $results = $bq->runQuery($job);
 
 foreach ($results->rows() as $row) {
     // 404 on second page fetch
 }

Any query that (a) takes the stateless path and (b) returns enough rows to paginate will fail.

Version

google/cloud-bigquery v1.36.0 (first version with stateless queries)

Workaround

Set an explicit jobId to force isStateless() to return false:

 $job = $bq->query('SELECT ...', [
     'jobReference' => ['jobId' => 'some-id'],
 ]);

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions