google-cloud-php: BigQuery: maxResults not working in $job->queryResults
I can’t get the maxResults option to work and have tried adding it to a few different places ($job->queryResults($options), inside $options['jobConfig'], inside $queryResults->reload($options) but no luck.
Am I doing something wrong here?
$job = $bigQuery->job($jobId); // assume $job->isComplete() === true
$options = ['maxResults' => 50];
$queryResults = $job->queryResults($options);
$count = 0;
foreach ($queryResults->rows() as $i => $row) {
++count;
}
Expected: $count should equal maxResults (50)
Actual: $count equals $job->info()['totalRows']
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (8 by maintainers)
Does this work?
SELECT * FROM table ORDER BY date DESC LIMIT 10 OFFSET 20@dwsupplee my goal is to do a pagination, exactly how mysql or mongodb does it. for example I have 100 rows. on my web page, I want to display 5 at time. so it gives me 20 buttons from 1-20, when I click page 2. it will display the rows 6-10. if doing it realistically I have 1m rows, displaying 50 per pages. I can really put LIMIT on the query, is there a skip,offset function on bigquery like how mysql is?
Ihave this setup on mysql now, but we are uploading our data bigquery.
What is the proper syntax for this:
{ select | ( query_expr ) | query_expr set_op query_expr } [ ORDER BY expression [{ ASC | DESC }] [, …] ] [ LIMIT count [ OFFSET skip_rows ] ]
SELECT * FROM table ORDER BY date DESC LIMIT 10,[OFFSET]?
Interesting. I ran an example locally very similar to yours and it was breaking out early - however, there may be a simpler way to achieve what you’re looking for now with #399.
If your goal is to only print out information from the first page of results:
If possible, I would recommend using a
LIMITclause.No problem, really glad to hear that!
If you don’t mind, I’m going to keep this issue open as a way to track updating the documentation of
maxResults. 😃