Skip to content

Commit

Permalink
rename job methods from start{Type} to create{Type}Job (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmehiphop authored and lukesneeringer committed Dec 27, 2017
1 parent ae75b00 commit 7d7ead6
Show file tree
Hide file tree
Showing 9 changed files with 2,342 additions and 2,336 deletions.
2 changes: 1 addition & 1 deletion samples/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function asyncQuery(sqlQuery, projectId) {

// Runs the query as a job
bigquery
.startQuery(options)
.createQueryJob(options)
.then(results => {
job = results[0];
console.log(`Job ${job.id} started.`);
Expand Down
53 changes: 28 additions & 25 deletions src/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,34 @@ function Dataset(bigQuery, id) {

util.inherits(Dataset, common.ServiceObject);

/**
* Run a query as a job. No results are immediately returned. Instead, your
* callback will be executed with a {@link Job} object that you must
* ping for the results. See the Job documentation for explanations of how to
* check on the status of the job.
*
* See {@link BigQuery#createQueryJob} for full documentation of this method.
*
* @param {object} options See {@link BigQuery#createQueryJob} for full documentation of this method.
* @param {function} [callback] See {@link BigQuery#createQueryJob} for full documentation of this method.
* @returns {Promise} See {@link BigQuery#createQueryJob} for full documentation of this method.
*/
Dataset.prototype.createQueryJob = function(options, callback) {
if (is.string(options)) {
options = {
query: options,
};
}

options = extend(true, {}, options, {
defaultDataset: {
datasetId: this.id,
},
});

return this.bigQuery.createQueryJob(options, callback);
};

/**
* Run a query scoped to your dataset as a readable object stream.
*
Expand Down Expand Up @@ -522,31 +550,6 @@ Dataset.prototype.query = function(options, callback) {
return this.bigQuery.query(options, callback);
};

/**
* Start running a query scoped to your dataset.
*
* See {@link BigQuery#startQuery} for full documentation of this method.
*
* @param {object} options See {@link BigQuery#startQuery} for full documentation of this method.
* @param {function} [callback] See {@link BigQuery#startQuery} for full documentation of this method.
* @returns {Promise} See {@link BigQuery#startQuery} for full documentation of this method.
*/
Dataset.prototype.startQuery = function(options, callback) {
if (is.string(options)) {
options = {
query: options,
};
}

options = extend(true, {}, options, {
defaultDataset: {
datasetId: this.id,
},
});

return this.bigQuery.startQuery(options, callback);
};

/**
* Create a Table object.
*
Expand Down
Loading

0 comments on commit 7d7ead6

Please sign in to comment.