Skip to content

Commit 40f8f80

Browse files
authored
docs(bigquery): improve RowIterator docs and out of process pagination with Storage API (#8419)
Fixes #7285, fixes #8373, fixes #8173
1 parent 2bfdc95 commit 40f8f80

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

bigquery/bigquery.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ func NewClient(ctx context.Context, projectID string, opts ...option.ClientOptio
101101

102102
// EnableStorageReadClient sets up Storage API connection to be used when fetching
103103
// large datasets from tables, jobs or queries.
104+
// Currently out of pagination methods like PageInfo().Token and RowIterator.StartIndex
105+
// are not supported when the Storage API is enabled.
104106
// Calling this method twice will return an error.
105107
func (c *Client) EnableStorageReadClient(ctx context.Context, opts ...option.ClientOption) error {
106108
if c.isStorageReadAvailable() {

bigquery/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ To retrieve the job's results from the ID, first look up the Job:
104104
}
105105
106106
Use the Job.Read method to obtain an iterator, and loop over the rows.
107-
Query.Read is just a convenience method that combines Query.Run and Job.Read.
107+
Calling Query.Read is preferred for queries with a relatively small result set,
108+
as it will call BigQuery jobs.query API for a optimized query path. If the query
109+
doesn't meet that criteria, the method will just combine Query.Run and Job.Read.
108110
109111
it, err = job.Read(ctx)
110112
if err != nil {

bigquery/iterator.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ type RowIterator struct {
5151
pf pageFetcher
5252

5353
// StartIndex can be set before the first call to Next. If PageInfo().Token
54-
// is also set, StartIndex is ignored.
54+
// is also set, StartIndex is ignored. If Storage API is enabled,
55+
// StartIndex is also ignored because is not supported. IsAccelerated()
56+
// method can be called to check if Storage API is enabled for the RowIterator.
5557
StartIndex uint64
5658

57-
// The schema of the table. Available after the first call to Next.
59+
// The schema of the table.
60+
// In some scenarios it will only be available after the first
61+
// call to Next(), like when a call to Query.Read uses
62+
// the jobs.query API for an optimized query path.
5863
Schema Schema
5964

60-
// The total number of rows in the result. Available after the first call to Next.
65+
// The total number of rows in the result.
66+
// In some scenarios it will only be available after the first
67+
// call to Next(), like when a call to Query.Read uses
68+
// the jobs.query API for an optimized query path.
6169
// May be zero just after rows were inserted.
6270
TotalRows uint64
6371

@@ -169,6 +177,8 @@ func isStructPtr(x interface{}) bool {
169177
}
170178

171179
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
180+
// Currently pagination is not supported when the Storage API is enabled. IsAccelerated()
181+
// method can be called to check if Storage API is enabled for the RowIterator.
172182
func (it *RowIterator) PageInfo() *iterator.PageInfo { return it.pageInfo }
173183

174184
func (it *RowIterator) fetch(pageSize int, pageToken string) (string, error) {

0 commit comments

Comments
 (0)