searain
searain

Reputation: 3301

bigquery queryresults rows pagintation configuration options?

https://googlecloudplatform.github.io/google-cloud-php/#/docs/v0.21.1/bigquery/table?method=rows

Bigquery table has method "rows". rows() method can take parameter "options", which can be used for pagination

Such as

$options = [
            'maxResults' => 3,
            'startIndex' => 0
        ];

$rows = $table->rows($options);

Now what I want is using pagination in bigquery queryresults rows() method

https://googlecloudplatform.github.io/google-cloud-php/#/docs/v0.21.1/bigquery/queryresults?method=rows

Here is the documentation for queryresults rows method. rows() also takes options as parameter. (But it does not give which field should be in the options).

$queryResults = $this->bigQuery->runQuery($query, ['useLegacySql' => false]);
$options = [
            'maxResults' => 3,
            'startIndex' => 0
        ];

$rows = $queryResults->rows($options);

But the options only ask for the top 3 records does not work. It still give me full set of queryresults rows.

Thanks!

Upvotes: 2

Views: 376

Answers (1)

david s
david s

Reputation: 289

https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.25.0/bigquery/bigqueryclient?method=runQuery

The maxResults option actually needs to be set on the runQuery call:

$queryResults = $this->bigQuery->runQuery($query, [
    'useLegacySql' => false,
    'maxResults' => 3
]);

Let me know if that does the trick for you.

Upvotes: 3

Related Questions