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

feat: clean cached rows and responses after conversion #1393

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,17 @@
private _universeDomain: string;
private _enableQueryPreview: boolean;

createQueryStream(options?: Query | string): ResourceStream<RowMetadata> {

Check warning on line 365 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
// placeholder body, overwritten in constructor
return new ResourceStream<RowMetadata>({}, () => {});
}

getDatasetsStream(options?: GetDatasetsOptions): ResourceStream<Dataset> {

Check warning on line 370 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
// placeholder body, overwritten in constructor
return new ResourceStream<Dataset>({}, () => {});
}

getJobsStream(options?: GetJobsOptions): ResourceStream<Job> {

Check warning on line 375 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
// placeholder body, overwritten in constructor
return new ResourceStream<Job>({}, () => {});
}
Expand Down Expand Up @@ -1569,7 +1569,7 @@
const parameterMode = is.array(params) ? 'positional' : 'named';
const queryParameters: bigquery.IQueryParameter[] = [];
if (parameterMode === 'named') {
const namedParams = params as {[param: string]: any};

Check warning on line 1572 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
for (const namedParameter of Object.getOwnPropertyNames(namedParams)) {
const value = namedParams[namedParameter];
let queryParameter;
Expand Down Expand Up @@ -2212,12 +2212,13 @@

options = extend({job}, queryOpts, options);
if (res && res.jobComplete) {
let rows: any = [];

Check warning on line 2215 in src/bigquery.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (res.schema && res.rows) {
rows = BigQuery.mergeSchemaWithRows_(res.schema, res.rows, {
wrapIntegers: options.wrapIntegers || false,
parseJSON: options.parseJSON,
});
delete res.rows;
}
this.trace_('[runJobsQuery] job complete');
options._cachedRows = rows;
Expand Down
13 changes: 8 additions & 5 deletions src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
/**
* internal properties
*/
_cachedRows?: any[];

Check warning on line 58 in src/job.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
_cachedResponse?: bigquery.IQueryResponse;
};

Expand Down Expand Up @@ -134,7 +134,7 @@
location?: string;
projectId?: string;
getQueryResultsStream(
options?: QueryResultsOptions

Check warning on line 137 in src/job.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
): ResourceStream<RowMetadata> {
// placeholder body, overwritten in constructor
return new ResourceStream<RowMetadata>({}, () => {});
Expand Down Expand Up @@ -565,16 +565,19 @@
const timeoutOverride =
typeof qs.timeoutMs === 'number' ? qs.timeoutMs : false;

if (options._cachedRows) {
const cachedRows = options._cachedRows;
const cachedResponse = options._cachedResponse;
delete options._cachedRows;
delete options._cachedResponse;
if (cachedRows) {
let nextQuery: QueryResultsOptions | null = null;
if (options.pageToken) {
nextQuery = Object.assign({}, options, {
pageToken: options.pageToken,
});
delete nextQuery._cachedRows;
delete nextQuery._cachedResponse;
}
callback!(null, options._cachedRows, nextQuery, options._cachedResponse);
delete cachedResponse?.rows;
callback!(null, cachedRows, nextQuery, cachedResponse);
return;
}

Expand Down Expand Up @@ -620,7 +623,7 @@
});
delete nextQuery.startIndex;
}

delete resp.rows;
callback!(null, rows, nextQuery, resp);
}
);
Expand Down
14 changes: 11 additions & 3 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

/**
* Discovery Revision: 20240629
* Discovery Revision: 20240714
*/

/**
Expand Down Expand Up @@ -858,7 +858,7 @@ declare namespace bigquery {
*/
type IDataset = {
/**
* Optional. An array of objects that define dataset access for one or more entities. You can set this property when inserting or updating a dataset in order to control who is allowed to access the data. If unspecified at dataset creation time, BigQuery adds default dataset access for the following entities: access.specialGroup: projectReaders; access.role: READER; access.specialGroup: projectWriters; access.role: WRITER; access.specialGroup: projectOwners; access.role: OWNER; access.userByEmail: [dataset creator email]; access.role: OWNER;
* Optional. An array of objects that define dataset access for one or more entities. You can set this property when inserting or updating a dataset in order to control who is allowed to access the data. If unspecified at dataset creation time, BigQuery adds default dataset access for the following entities: access.specialGroup: projectReaders; access.role: READER; access.specialGroup: projectWriters; access.role: WRITER; access.specialGroup: projectOwners; access.role: OWNER; access.userByEmail: [dataset creator email]; access.role: OWNER; If you patch a dataset, then this field is overwritten by the patched dataset's access field. To add entities, you must supply the entire existing access array in addition to any new entities that you want to add.
*/
access?: Array<{
/**
Expand Down Expand Up @@ -1013,7 +1013,7 @@ declare namespace bigquery {
| 'LOGICAL'
| 'PHYSICAL';
/**
* Output only. Tags for the Dataset.
* Output only. Tags for the dataset. To provide tags as inputs, use the `resourceTags` field.
*/
tags?: Array<{
/**
Expand Down Expand Up @@ -2754,6 +2754,14 @@ declare namespace bigquery {
* Output only. Statistics for data-masking. Present only for query and extract jobs.
*/
dataMaskingStatistics?: IDataMaskingStatistics;
/**
* Output only. Name of edition corresponding to the reservation for this job at the time of this update.
*/
edition?:
| 'RESERVATION_EDITION_UNSPECIFIED'
| 'STANDARD'
| 'ENTERPRISE'
| 'ENTERPRISE_PLUS';
/**
* Output only. End time of this job, in milliseconds since the epoch. This field will be present whenever a job is in the DONE state.
*/
Expand Down
Loading