1
votes

I am using this php client library to pull the BigQuery data. (https://github.com/googleapis/google-cloud-php-bigquery )

The issue is that I am not able to paginate the BigQuery data. Here is how I pulled the data. The link clear shows how we can pull data but does not give any information on paginating the data.

https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-install-php

1
Does this answer your question? Paginating BigQuery - segFault

1 Answers

1
votes

Pagination docs are elsewhere

https://cloud.google.com/bigquery/docs/paging-results#bigquery_browse_table-php

Basically the code will be:

$maxResults = 10;
$startIndex = 0;

$options = [
    'maxResults' => $maxResults,
    'startIndex' => $startIndex
];
$bigQuery = new BigQueryClient([
    'projectId' => $projectId,
]);
$dataset = $bigQuery->dataset($datasetId);
$table = $dataset->table($tableId);
$numRows = 0;
foreach ($table->rows($options) as $row) {
    print('---');
    foreach ($row as $column => $value) {
        printf('%s: %s' . PHP_EOL, $column, $value);
    }
    $numRows++;
}