Socket
Socket
Sign inDemoInstall

@google-cloud/bigquery

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/bigquery - npm Package Compare versions

Comparing version 5.3.0 to 5.4.0

90

build/src/bigquery.d.ts

@@ -59,6 +59,10 @@ /*!

maxResults?: number;
timeoutMs?: number;
jobTimeoutMs?: number;
pageToken?: string;
wrapIntegers?: boolean | IntegerTypeCastOptions;
};
export declare type QueryOptions = QueryResultsOptions;
export declare type QueryStreamOptions = {
wrapIntegers?: boolean | IntegerTypeCastOptions;
};
export declare type DatasetResource = bigquery.IDataset;

@@ -110,2 +114,10 @@ export declare type ValueType = bigquery.IQueryParameterType;

}
export interface IntegerTypeCastOptions {
integerTypeCastFunction: Function;
fields?: string | string[];
}
export declare type IntegerTypeCastValue = {
integerValue: string | number;
schemaFieldName?: string;
};
export declare const PROTOCOL_REGEX: RegExp;

@@ -195,2 +207,8 @@ /**

* @param {array} rows
* @param {boolean|IntegerTypeCastOptions} wrapIntegers Wrap values of
* 'INT64' type in {@link BigQueryInt} objects.
* If a `boolean`, this will wrap values in {@link BigQueryInt} objects.
* If an `object`, this will return a value returned by
* `wrapIntegers.integerTypeCastFunction`.
* Please see {@link IntegerTypeCastOptions} for options descriptions.
* @param {array} selectedFields List of fields to return.

@@ -200,3 +218,3 @@ * If unspecified, all fields are returned.

*/
static mergeSchemaWithRows_(schema: TableSchema | TableField, rows: TableRow[], selectedFields?: string[]): any[];
static mergeSchemaWithRows_(schema: TableSchema | TableField, rows: TableRow[], wrapIntegers: boolean | IntegerTypeCastOptions, selectedFields?: string[]): any[];
/**

@@ -405,2 +423,27 @@ * The `DATE` type represents a logical calendar date, independent of time

/**
* A BigQueryInt wraps 'INT64' values. Can be used to maintain precision.
*
* @method BigQuery#int
* @param {string|number|IntegerTypeCastValue} value The INT64 value to convert.
* @param {IntegerTypeCastOptions} typeCastOptions Configuration to convert
* value. Must provide an `integerTypeCastFunction` to handle conversion.
*
* @example
* const {BigQuery} = require('@google-cloud/bigquery');
* const bigquery = new BigQuery();
*
* const largeIntegerValue = Number.MAX_SAFE_INTEGER + 1;
*
* const options = {
* integerTypeCastFunction: value => value.split(),
* };
*
* const bqInteger = bigquery.int(largeIntegerValue, options);
*
* const customValue = bqInteger.valueOf();
* // customValue is the value returned from your `integerTypeCastFunction`.
*/
static int(value: string | number | IntegerTypeCastValue, typeCastOptions?: IntegerTypeCastOptions): BigQueryInt;
int(value: string | number | IntegerTypeCastValue, typeCastOptions?: IntegerTypeCastOptions): BigQueryInt;
/**
* A geography value represents a surface area on the Earth

@@ -431,2 +474,9 @@ * in Well-known Text (WKT) format.

/**
* Convert an INT64 value to Number.
*
* @private
* @param {object} value The INT64 value to convert.
*/
static decodeIntegerValue_(value: IntegerTypeCastValue): number;
/**
* Return a value's provided type.

@@ -465,5 +515,9 @@ *

* @param {*} value The value.
* @param {string|ProvidedTypeStruct|ProvidedTypeArray} providedType Provided
* query parameter type.
* @returns {object} A properly-formed `queryParameter` object.
*/
static valueToQueryParameter_(value: any, providedType?: string | ProvidedTypeStruct | ProvidedTypeArray): bigquery.IQueryParameter;
private static _getValue;
private static _isCustomType;
createDataset(id: string, options?: DatasetResource): Promise<DatasetResponse>;

@@ -525,3 +579,3 @@ createDataset(id: string, options: DatasetResource, callback: DatasetCallback): void;

*/
queryAsStream_(query: Query, callback?: SimpleQueryRowsCallback): void;
queryAsStream_(query: Query, optionsOrCallback?: QueryStreamOptions, cb?: SimpleQueryRowsCallback): void;
}

@@ -563,1 +617,31 @@ /**

}
/**
* Build a BigQueryInt object. For long integers, a string can be provided.
*
* @class
* @param {string|number|IntegerTypeCastValue} value The 'INT64' value.
* @param {object} [typeCastOptions] Configuration to convert
* values of 'INT64' type to a custom value. Must provide an
* `integerTypeCastFunction` to handle conversion.
* @param {function} typeCastOptions.integerTypeCastFunction A custom user
* provided function to convert value.
* @param {string|string[]} [typeCastOptions.fields] Schema field
* names to be converted using `integerTypeCastFunction`.
*
* @example
* const {BigQuery} = require('@google-cloud/bigquery');
* const bigquery = new BigQuery();
* const anInt = bigquery.int(7);
*/
export declare class BigQueryInt extends Number {
type: string;
value: string;
typeCastFunction?: Function;
private _schemaFieldName;
constructor(value: string | number | IntegerTypeCastValue, typeCastOptions?: IntegerTypeCastOptions);
valueOf(): any;
toJSON(): Json;
}
export interface Json {
[field: string]: string;
}

2

build/src/index.d.ts

@@ -16,3 +16,3 @@ /*!

*/
export { BigQuery, BigQueryDate, BigQueryDateOptions, BigQueryDatetime, BigQueryDatetimeOptions, BigQueryOptions, BigQueryTime, BigQueryTimeOptions, BigQueryTimestamp, DatasetCallback, DatasetResource, DatasetResponse, DatasetsCallback, DatasetsResponse, Geography, GetDatasetsOptions, GetJobsCallback, GetJobsOptions, GetJobsResponse, JobRequest, PagedCallback, PagedRequest, PagedResponse, PROTOCOL_REGEX, Query, QueryOptions, QueryParameter, QueryRowsCallback, QueryRowsResponse, RequestCallback, ResourceCallback, SimpleQueryRowsCallback, SimpleQueryRowsResponse, ValueType, } from './bigquery';
export { BigQuery, BigQueryDate, BigQueryDateOptions, BigQueryDatetime, BigQueryDatetimeOptions, BigQueryInt, BigQueryOptions, BigQueryTime, BigQueryTimeOptions, BigQueryTimestamp, DatasetCallback, DatasetResource, DatasetResponse, DatasetsCallback, DatasetsResponse, Geography, GetDatasetsOptions, GetJobsCallback, GetJobsOptions, GetJobsResponse, IntegerTypeCastOptions, IntegerTypeCastValue, JobRequest, Json, PagedCallback, PagedRequest, PagedResponse, PROTOCOL_REGEX, Query, QueryOptions, QueryParameter, QueryRowsCallback, QueryRowsResponse, RequestCallback, ResourceCallback, SimpleQueryRowsCallback, SimpleQueryRowsResponse, ValueType, } from './bigquery';
export { CreateDatasetOptions, Dataset, DatasetDeleteOptions, DatasetOptions, GetModelsCallback, GetModelsOptions, GetModelsResponse, GetRoutinesCallback, GetRoutinesOptions, GetRoutinesResponse, GetTablesCallback, GetTablesOptions, GetTablesResponse, RoutineCallback, RoutineMetadata, RoutineResponse, TableCallback, TableResponse, } from './dataset';

@@ -19,0 +19,0 @@ export { CancelCallback, CancelResponse, Job, JobMetadata, JobOptions, QueryResultsOptions, } from './job';

@@ -22,2 +22,3 @@ "use strict";

Object.defineProperty(exports, "BigQueryDatetime", { enumerable: true, get: function () { return bigquery_1.BigQueryDatetime; } });
Object.defineProperty(exports, "BigQueryInt", { enumerable: true, get: function () { return bigquery_1.BigQueryInt; } });
Object.defineProperty(exports, "BigQueryTime", { enumerable: true, get: function () { return bigquery_1.BigQueryTime; } });

@@ -24,0 +25,0 @@ Object.defineProperty(exports, "BigQueryTimestamp", { enumerable: true, get: function () { return bigquery_1.BigQueryTimestamp; } });

@@ -21,3 +21,3 @@ /*!

import { ResourceStream } from '@google-cloud/paginator';
import { BigQuery, JobRequest, PagedRequest, QueryRowsCallback, QueryRowsResponse, RequestCallback } from './bigquery';
import { BigQuery, IntegerTypeCastOptions, JobRequest, PagedRequest, QueryRowsCallback, QueryRowsResponse, RequestCallback } from './bigquery';
import { RowMetadata } from './table';

@@ -31,2 +31,3 @@ import bigquery from './types';

job?: Job;
wrapIntegers?: boolean | IntegerTypeCastOptions;
} & PagedRequest<bigquery.jobs.IGetQueryResultsParams>;

@@ -33,0 +34,0 @@ /**

@@ -283,5 +283,10 @@ "use strict";

* @param {number} [options.timeoutMs] How long to wait for the query to
* complete, in milliseconds, before returning. Default is to return
* immediately. If the timeout passes before the job completes, the
* request will fail with a `TIMEOUT` error.
* complete, in milliseconds, before returning. Default is 10 seconds.
* If the timeout passes before the job completes, an error will be returned
* and the 'jobComplete' field in the response will be false.
* @param {boolean|IntegerTypeCastOptions} [options.wrapIntegers=false] Wrap values
* of 'INT64' type in {@link BigQueryInt} objects.
* If a `boolean`, this will wrap values in {@link BigQueryInt} objects.
* If an `object`, this will return a value returned by
* `wrapIntegers.integerTypeCastFunction`.
* @param {QueryResultsCallback|ManualQueryResultsCallback} [callback] The

@@ -342,3 +347,6 @@ * callback function. If `autoPaginate` is set to false a

}, options);
const wrapIntegers = qs.wrapIntegers ? qs.wrapIntegers : false;
delete qs.wrapIntegers;
delete qs.job;
const timeoutOverride = typeof qs.timeoutMs === 'number' ? qs.timeoutMs : false;
this.bigQuery.request({

@@ -355,3 +363,3 @@ uri: '/queries/' + this.id,

if (resp.schema && resp.rows) {
rows = bigquery_1.BigQuery.mergeSchemaWithRows_(resp.schema, resp.rows);
rows = bigquery_1.BigQuery.mergeSchemaWithRows_(resp.schema, resp.rows, wrapIntegers);
}

@@ -362,2 +370,8 @@ let nextQuery = null;

nextQuery = Object.assign({}, options);
// If timeout override was provided, return error.
if (timeoutOverride) {
const err = new Error(`The query did not complete before ${timeoutOverride}ms`);
callback(err, null, nextQuery, resp);
return;
}
}

@@ -364,0 +378,0 @@ else if (resp.pageToken) {

@@ -23,2 +23,3 @@ /*!

import bigquery from './types';
import { IntegerTypeCastOptions } from './bigquery';
export interface File {

@@ -51,3 +52,5 @@ bucket: any;

export declare type TableRowValue = string | TableRow;
export declare type GetRowsOptions = PagedRequest<bigquery.tabledata.IListParams>;
export declare type GetRowsOptions = PagedRequest<bigquery.tabledata.IListParams> & {
wrapIntegers?: boolean | IntegerTypeCastOptions;
};
export declare type JobLoadMetadata = JobRequest<bigquery.IJobConfigurationLoad> & {

@@ -54,0 +57,0 @@ format?: string;

@@ -7,2 +7,17 @@ # Changelog

## [5.4.0](https://www.github.com/googleapis/nodejs-bigquery/compare/v5.3.0...v5.4.0) (2020-11-02)
### Features
* optionally wrap INT64 in BigQueryInt or provide a custom INT64 value type cast options ([#873](https://www.github.com/googleapis/nodejs-bigquery/issues/873)) ([be7c6e6](https://www.github.com/googleapis/nodejs-bigquery/commit/be7c6e6411e351bfab4b557fb34162470bbfd7f4))
### Bug Fixes
* Detect Geography type during parameterized query ([#877](https://www.github.com/googleapis/nodejs-bigquery/issues/877)) ([bc0ca69](https://www.github.com/googleapis/nodejs-bigquery/commit/bc0ca695a5b2d9df15df9383f6a791be30e851ec))
* do not retry jobs.insert when it flakes ([#864](https://www.github.com/googleapis/nodejs-bigquery/issues/864)) ([255491b](https://www.github.com/googleapis/nodejs-bigquery/commit/255491b958171907695b10aca7e536d58a52354c))
* return error when custom getQueryResults() timeout has been exceeded ([#872](https://www.github.com/googleapis/nodejs-bigquery/issues/872)) ([96f939c](https://www.github.com/googleapis/nodejs-bigquery/commit/96f939cefe2f31a5252002bbfecd5f503b32f841))
* **deps:** update dependency big.js to v6 ([#862](https://www.github.com/googleapis/nodejs-bigquery/issues/862)) ([a47afb5](https://www.github.com/googleapis/nodejs-bigquery/commit/a47afb5c97115d0159ad94615a7997db15d03d01))
## [5.3.0](https://www.github.com/googleapis/nodejs-bigquery/compare/v5.2.0...v5.3.0) (2020-09-30)

@@ -9,0 +24,0 @@

{
"name": "@google-cloud/bigquery",
"description": "Google BigQuery Client Library for Node.js",
"version": "5.3.0",
"version": "5.4.0",
"license": "Apache-2.0",

@@ -57,3 +57,3 @@ "author": "Google LLC",

"arrify": "^2.0.1",
"big.js": "^5.2.2",
"big.js": "^6.0.0",
"duplexify": "^4.0.0",

@@ -68,3 +68,3 @@ "extend": "^3.0.2",

"@google-cloud/storage": "^5.0.0",
"@types/big.js": "^4.0.5",
"@types/big.js": "^6.0.0",
"@types/execa": "^0.9.0",

@@ -71,0 +71,0 @@ "@types/extend": "^3.0.1",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc