google-cloud-go icon indicating copy to clipboard operation
google-cloud-go copied to clipboard

bigquery: total rows has incorrect value

Open zecke opened this issue 9 months ago • 0 comments

Client

bigquery

Environment

Go 1.22

Code and Dependencies

package main

func main() {
    // ...
    var values []bigquery.Value
    err := it.Next(&values)
    if err == iterator.Done {
        return
    }
    if err != nil {
        // TODO: Handle error.
    }
    fmt.Println(it.TotalRows)
}

Expected behavior

it.TotalRows() should have the correct value after the first call to RowIterator.Next(context.Context)

Actual behavior

When the first call of it.Next(ctx) hits the paged cache the length of the cache is returned and not the total number of rows.

https://github.com/googleapis/google-cloud-go/blob/c2ee207621b2bb5fad8e6821892eae0041f469cd/bigquery/iterator.go#L409

zecke avatar Mar 19 '25 14:03 zecke