Skip to content

Commit 57922bc

Browse files
committed
pr comment
1 parent 8bd5f3e commit 57922bc

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Copyright 2014 Google Inc. All Rights Reserved.
2+
* Copyright 2017 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,17 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17+
'use strict';
18+
1719
const async = require('async');
1820
const fs = require('fs');
19-
const util = require('util');
2021
const BigQuery = require('../src/index.js');
2122

2223
if (process.argv.length < 3) {
23-
throw util.format("need query file; usage: '%s %s <queries.json>'", process.argv[0], process.argv[1]);
24+
throw `need query file; usage: \
25+
'${process.argv[0]} ${process.argv[1]} <queries.json>'`;
2426
}
2527
var queryJson = fs.readFileSync(process.argv[2]);
2628
var queries = JSON.parse(queryJson);
27-
var client = BigQuery();
29+
var client = new BigQuery();
2830

2931
var doQuery = function(queryTxt, callback) {
3032
var startMilli = new Date().getTime();
@@ -39,31 +41,30 @@ var doQuery = function(queryTxt, callback) {
3941

4042
client.createQueryStream(query)
4143
.on('error', function(err) {
42-
callback(err)
44+
callback(err);
4345
})
4446
.on('data', function(row) {
45-
if (numRows == 0) {
47+
if (numRows === 0) {
4648
numCols = Object.keys(row).length;
4749
timeFirstByteMilli = new Date().getTime() - startMilli;
48-
} else if (numCols != Object.keys(row).length) {
50+
} else if (numCols !== Object.keys(row).length) {
4951
this.end();
50-
callback(util.format("query %j: wrong number of columns, want %d got %d",
51-
queryTxt,
52-
numCols,
53-
Object.keys(row).length));
52+
callback(`query "${queryTxt}": wrong number of columns, \
53+
want ${numCols} got ${Object.keys(row).length}`);
5454
}
5555
numRows++;
5656
})
5757
.on('end', function() {
58-
timeTotalMilli = new Date().getTime() - startMilli;
59-
console.log(util.format("query %j: got %d rows, %d cols, first byte %d sec, total %d sec",
60-
queryTxt,
61-
numRows,
62-
numCols,
63-
timeFirstByteMilli/1000,
64-
timeTotalMilli/1000));
58+
var timeTotalMilli = new Date().getTime() - startMilli;
59+
console.log(`query ${queryTxt}: got ${numRows} rows, ${numCols} cols, \
60+
first byte ${timeFirstByteMilli / 1000} sec, \
61+
total ${timeTotalMilli / 1000} sec`);
6562
callback(null);
6663
});
67-
}
64+
};
6865

69-
async.eachSeries(queries, doQuery, err =>{});
66+
async.eachSeries(queries, doQuery, err => {
67+
if (err) {
68+
console.error(err);
69+
}
70+
});

0 commit comments

Comments
 (0)