Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return Total Rows #431

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions lib/bigquery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,28 +391,27 @@ BigQuery.prototype.query = function(options, callback) {
return;
}

var job = that.job(resp.jobReference.jobId);
var nextQuery = null;
var rows = Table.mergeSchemaWithRows_(resp.schema, resp.rows || []);

if (resp.jobComplete === false) {
// Query is still running.
nextQuery = extend({
job: job
}, options);
} else if (resp.pageToken) {
// More results exist.
nextQuery = extend({
job: job
}, options, {
pageToken: resp.pageToken
});
}

onComplete(null, rows, nextQuery);
var nextQuery = null;
var rows = Table.mergeSchemaWithRows_(resp.schema, resp.rows || []);

if (resp.jobComplete === false) {
// Query is still running.
nextQuery = extend({
job: that.job(options.job.id)
}, options);
} else if (resp.pageToken) {
// More results exist.
nextQuery = extend({
job: that.job(resp.jobReference.jobId)
}, options, {
pageToken: resp.pageToken
});
}

onComplete(null, rows, nextQuery, resp);
}

function onComplete(err, rows, nextQuery) {
function onComplete(err, rows, nextQuery, resp) {
if (err) {
if (stream) {
stream.emit('error', err);
Expand All @@ -434,7 +433,7 @@ BigQuery.prototype.query = function(options, callback) {
stream.end();
}
} else {
callback(null, rows, nextQuery);
callback(null, rows, nextQuery, resp);
}
}
}
Expand Down