Skip to content

Commit

Permalink
Change triggered by none of the following:
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Apr 1, 2020
1 parent 3f78914 commit 390e777
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 285 deletions.
21 changes: 0 additions & 21 deletions README.md
Expand Up @@ -162,27 +162,6 @@ has instructions for running the samples.
The [Google Cloud BigQuery Node.js Client API Reference][client-docs] documentation
also contains samples.

## Supported Node.js Versions

Our client libraries follow the [Node.js release schedule](https://nodejs.org/en/about/releases/).
Libraries are compatible with all current _active_ and _maintenance_ versions of
Node.js.

Client libraries targetting some end-of-life versions of Node.js are available, and
can be installed via npm [dist-tags](https://docs.npmjs.com/cli/dist-tag).
The dist-tags follow the naming convention `legacy-(version)`.

_Legacy Node.js versions are supported as a best effort:_

* Legacy versions will not be tested in continuous integration.
* Some security patches may not be able to be backported.
* Dependencies will not be kept up-to-date, and features will not be backported.

#### Legacy tags available

* `legacy-8`: install client libraries from this dist-tag for versions
compatible with Node.js 8.

## Versioning

This library follows [Semantic Versioning](http://semver.org/).
Expand Down
9 changes: 4 additions & 5 deletions package.json
Expand Up @@ -5,7 +5,7 @@
"license": "Apache-2.0",
"author": "Google LLC",
"engines": {
"node": ">=10"
"node": ">=8.10.0"
},
"repository": "googleapis/nodejs-bigquery",
"main": "./build/src/index.js",
Expand Down Expand Up @@ -49,15 +49,14 @@
"prelint": "cd samples; npm link ../; npm i"
},
"dependencies": {
"@google-cloud/common": "^3.0.0",
"@google-cloud/paginator": "^3.0.0",
"@google-cloud/promisify": "^2.0.0",
"@google-cloud/common": "^2.0.0",
"@google-cloud/paginator": "^2.0.0",
"@google-cloud/promisify": "^1.0.0",
"arrify": "^2.0.1",
"big.js": "^5.2.2",
"duplexify": "^4.0.0",
"extend": "^3.0.2",
"is": "^3.3.0",
"p-event": "^4.1.0",
"stream-events": "^1.0.5",
"string-format-obj": "^1.1.1",
"uuid": "^7.0.0"
Expand Down
2 changes: 1 addition & 1 deletion samples/package.json
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@google-cloud/bigquery": "^4.7.0",
"@google-cloud/storage": "^4.0.0",
"google-auth-library": "^6.0.0",
"google-auth-library": "^5.8.0",
"readline-promise": "^1.0.4",
"yargs": "^15.0.0"
},
Expand Down
57 changes: 24 additions & 33 deletions src/table.ts
Expand Up @@ -20,7 +20,6 @@ import {promisifyAll} from '@google-cloud/promisify';
import arrify = require('arrify');
import Big from 'big.js';
import * as extend from 'extend';
import pEvent from 'p-event';

const format = require('string-format-obj');
import * as fs from 'fs';
Expand Down Expand Up @@ -1103,16 +1102,20 @@ class Table extends common.ServiceObject {
this.bigQuery.createJob(body, callback!);
}

createLoadJob(source: string, metadata?: JobLoadMetadata): Writable;
createLoadJob(source: File, metadata?: JobLoadMetadata): Promise<JobResponse>;
createLoadJob(
source: string | File,
metadata?: JobLoadMetadata
): Promise<JobResponse>;
source: string,
metadata: JobLoadMetadata,
callback: JobCallback
): Writable;
createLoadJob(
source: string | File,
source: File,
metadata: JobLoadMetadata,
callback: JobCallback
): void;
createLoadJob(source: string | File, callback: JobCallback): void;
createLoadJob(source: string, callback: JobCallback): Writable;
createLoadJob(source: File, callback: JobCallback): void;
/**
* Load data from a local file or Storage {@link
* https://cloud.google.com/nodejs/docs/reference/storage/latest/File File}.
Expand All @@ -1126,10 +1129,10 @@ class Table extends common.ServiceObject {
*
* @see [Jobs: insert API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/v2/jobs/insert}
*
* @param {string|File|File[]} source The source file to load. A string (path)
* to a local file, or one or more {@link
* @param {string|File} source The source file to load. A string or a
* {@link
* https://cloud.google.com/nodejs/docs/reference/storage/latest/File File}
* objects.
* object.
* @param {object} [metadata] Metadata to set with the load operation. The
* metadata object should be in the format of the
* [`configuration.load`](http://goo.gl/BVcXk4) property of a Jobs
Expand Down Expand Up @@ -1200,31 +1203,17 @@ class Table extends common.ServiceObject {
* });
*/
createLoadJob(
source: string | File | File[],
source: string | File,
metadataOrCallback?: JobLoadMetadata | JobCallback,
cb?: JobCallback
): void | Promise<JobResponse> {
): void | Promise<JobResponse> | Writable {
const metadata =
typeof metadataOrCallback === 'object' ? metadataOrCallback : {};
const callback =
typeof metadataOrCallback === 'function' ? metadataOrCallback : cb;

this._createLoadJob(source, metadata).then(
([resp]) => callback!(null, resp, resp.metadata),
err => callback!(err)
);
}
typeof metadataOrCallback === 'function'
? metadataOrCallback
: cb || common.util.noop;

/**
* @param {string | File | File[]} source
* @param {JobLoadMetadata} metadata
* @returns {Promise<JobResponse>}
* @private
*/
async _createLoadJob(
source: string | File | File[],
metadata: JobLoadMetadata
): Promise<JobResponse> {
if (metadata.format) {
metadata.sourceFormat = FORMATS[metadata.format.toLowerCase()];
delete metadata.format;
Expand All @@ -1249,11 +1238,13 @@ class Table extends common.ServiceObject {
}

// Read the file into a new write stream.
const jobWritable = fs
return fs
.createReadStream(source)
.pipe(this.createWriteStream_(metadata));
const jobResponse = (await pEvent(jobWritable, 'job')) as Job;
return [jobResponse, jobResponse.metadata];
.pipe(this.createWriteStream_(metadata))
.on('error', callback)
.on('job', job => {
callback(null, job, job.metadata);
});
}

// tslint:disable-next-line no-any
Expand Down Expand Up @@ -1307,7 +1298,7 @@ class Table extends common.ServiceObject {
}),
});

return this.bigQuery.createJob(body);
this.bigQuery.createJob(body, callback);
}

createQueryJob(options: Query): Promise<JobResponse>;
Expand Down

0 comments on commit 390e777

Please sign in to comment.