@flytedesk/app-kit 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/bigquery/errors.d.ts +34 -8
- package/dist/bigquery/errors.js +180 -22
- package/dist/bigquery/errors.js.map +1 -1
- package/dist/bigquery/index.d.ts +2 -1
- package/dist/bigquery/index.js +1 -1
- package/dist/bigquery/index.js.map +1 -1
- package/dist/bigquery/jobIdentity.d.ts +39 -0
- package/dist/bigquery/jobIdentity.js +83 -0
- package/dist/bigquery/jobIdentity.js.map +1 -0
- package/dist/bigquery/load.d.ts +11 -14
- package/dist/bigquery/load.js +132 -56
- package/dist/bigquery/load.js.map +1 -1
- package/dist/bigquery/query.d.ts +19 -1
- package/dist/bigquery/query.js +143 -50
- package/dist/bigquery/query.js.map +1 -1
- package/dist/bigquery/retry.d.ts +56 -0
- package/dist/bigquery/retry.js +110 -0
- package/dist/bigquery/retry.js.map +1 -0
- package/dist/bigquery/types.d.ts +40 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -364,9 +364,21 @@ fails the whole call. A partially rejected insert throws `InsertRowsPartialFailu
|
|
|
364
364
|
keeps each row's `{reason, message}` entries); a rate-limit/quota reason throws `RateLimitExceededError`
|
|
365
365
|
and a 403 `PermissionDeniedError`. There is no retry. A table without `insert` throws `BigQueryReadError`.
|
|
366
366
|
|
|
367
|
-
**
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
**Transient failures and retry** — `runQuery`, `runQueryAllPages`, `estimateQueryBytes` and the load helpers retry with exponential backoff (`attempts` default 5, a positive integer counted across every step of one call; `initialDelayMs` default 1000, doubling; `sleep` and `now` for tests). Which step is repeated follows Google's [error table](https://cloud.google.com/bigquery/docs/error-messages), not "start the job again":
|
|
368
|
+
|
|
369
|
+
- **A request about an existing job** (checking its status, fetching its results) that fails with `backendError`, `internalError`, `tableUnavailable` or `rateLimitExceeded` is repeated against **that same job id**; a second job is never created for it.
|
|
370
|
+
- **The job itself failing** — it reports `jobBackendError`, `jobInternalError` or `jobRateLimitExceeded`, or it finished failed with any other transient reason and no HTTP `code` (a failure the job reports carries none; a failed request always does, and re-checking a finished job would only report it again) — submits a **new job** (new job id). A failure **creating** the job does not by itself start another: see the next point. A job that exists but has not finished (`status.errors` on a RUNNING job, which is what the SDK's `createJob` rejects with) has not failed, whatever its `status.errors` names (even a non-transient warning, which the SDK rejects with all the same): it is waited on under its id, and the error is thrown only for a job-reported failure (DONE with an `errorResult`) or a caller fault.
|
|
371
|
+
- These are classified `TransientBackendError` (backend reasons, HTTP 400 or 5xx, never `BadQueryError`) or `RateLimitExceededError`. A caller fault listed beside a transient reason in `errors[]` (`invalidQuery`, `accessDenied`, ...) wins: nothing is retried. Any other error is classified and thrown on the first attempt.
|
|
372
|
+
- `quotaExceeded` still classifies as `RateLimitExceededError` but `runQuery` / `estimateQueryBytes` do not retry it: Google gives no retry guidance for it. The load helpers retried it before and still do.
|
|
373
|
+
- A new job is submitted after a job-level failure, so a script that changes data outside one transaction (a re-run may repeat its changes) passes `attempts: 1`. A script whose changes are all in one transaction, a query, and `CREATE ... IF NOT EXISTS`-style statements are safe to resubmit.
|
|
374
|
+
- Fetching a later page (`pageToken`) is a single request and is never retried.
|
|
375
|
+
- **One job id per logical job.** `runQuery` and the load helpers choose the job id once (`options.jobId ?? randomUUID()`) and submit every attempt under it, because Google says the outcome of a failed `jobs.insert` is unclear. Before submitting again they look the id up: found means wait on that job, a 404 means it was never created so submit under the SAME id, and a 409 on submitting means it exists. A new id (a new job) is taken only when the job itself reports a failure, because that job is final.
|
|
376
|
+
- **The load helpers cannot append twice.** A stream load confirms its job from the library's `job` event, a load from Cloud Storage URIs from `createJob`. Once the job is confirmed, a failed request about it — `backendError`, `internalError`, `tableUnavailable`, `rateLimitExceeded`, and `quotaExceeded`, which loads have always retried — waits on that same job again and never submits a second load. A failure before the job is confirmed looks the id up first, as above. So a retry never appends a `WRITE_APPEND` load's rows twice.
|
|
377
|
+
- **BigQuery jobs are per location.** A job in `us-central1` looked up without a location answers "Not found", and submitting its id again answers 409 "Already Exists". So the job's location travels with it: the one reported by the `job` event, by `createJob`, or by the job a lookup found, and otherwise the one it was submitted with. Pass `location` (to `runQuery`, `loadRowsWithRetry` and `loadFromUrisWithRetry`) for any data outside the US and EU multi-regions, or the lookup after a failed submission cannot find the job. `QueryPage.location` carries the location BigQuery reported, and `runQueryAllPages` passes it to every later page. The load helpers' `location` also opens the dataset (`bq.dataset(id, { location })`) and creates a URI load's job there.
|
|
378
|
+
- **A load's `jobId` is now the id the job is submitted under, and reusing one is not an error.** In v8.0.0 `BigQueryLoadOptions.jobId` reached only a stream load, where an id that already existed failed with a 409. Now both load helpers use it (a random id when omitted), and an id that already exists means that job is waited on and ITS result returned (for a stream load, the rows it counted when the job exists from this call, otherwise the `outputRows` BigQuery reports): nothing is loaded again. Give each logical load its own id.
|
|
379
|
+
- When attempts or the time budget run out, the transient error is thrown, classified, with the attempt count in its message.
|
|
380
|
+
|
|
381
|
+
**Client-side wait bound** — `jobTimeoutMs` is ONE total budget for the whole `runQuery` / `estimateQueryBytes` call: the creation of every job, every results wait, and every retry backoff. Each job is created with a `jobTimeoutMs` of only what remains, and every `getQueryResults` waits at most what remains (its SDK "did not complete before Nms" rejection surfaces as `JobTimeoutError`, as does BigQuery stopping a job). No attempt or request starts once the budget is spent (a backoff is clamped to what remains); the transient error is then thrown, classified, with the attempt count. A later-page fetch (`pageToken`) passes `jobTimeoutMs` as its `timeoutMs` unchanged.
|
|
370
382
|
|
|
371
383
|
**Row unwrapping** — `unwrapBigQueryRow(row)` returns a new object with `unwrapBigQueryValue`
|
|
372
384
|
applied to every field.
|
|
@@ -24,6 +24,14 @@ export declare class PermissionDeniedError extends BigQueryReadError {
|
|
|
24
24
|
export declare class RateLimitExceededError extends BigQueryReadError {
|
|
25
25
|
constructor(message: string, cause?: unknown);
|
|
26
26
|
}
|
|
27
|
+
/** BigQuery failed on its own side (`jobBackendError`, `backendError`,
|
|
28
|
+
* `internalError`, `jobInternalError`, `tableUnavailable`; Google's message for the first reads
|
|
29
|
+
* "Retrying the job may solve the problem"). Transient, and the caller's
|
|
30
|
+
* request is not at fault, so it is distinct from BadQueryError even when
|
|
31
|
+
* Google reports it with HTTP 400. Retried like RateLimitExceededError. */
|
|
32
|
+
export declare class TransientBackendError extends BigQueryReadError {
|
|
33
|
+
constructor(message: string, cause?: unknown);
|
|
34
|
+
}
|
|
27
35
|
/** A dry-run estimate exceeded the caller-supplied byte budget — thrown
|
|
28
36
|
* before any billable query actually runs. */
|
|
29
37
|
export declare class DryRunBudgetExceededError extends BigQueryReadError {
|
|
@@ -78,14 +86,32 @@ export declare class InsertRowsPartialFailureError extends BigQueryReadError {
|
|
|
78
86
|
* throws itself — always returns an Error to `throw` at the call site.
|
|
79
87
|
*/
|
|
80
88
|
export declare function classifyBigQueryError(err: unknown): BigQueryReadError;
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
/** What a call retries. `quota` also retries `quotaExceeded`: Google gives no
|
|
90
|
+
* retry guidance for it, so queries leave it off; the load helpers retried it
|
|
91
|
+
* before SMS-293 and keep it on. */
|
|
92
|
+
export interface TransientPolicy {
|
|
93
|
+
quota?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/** True when `err` is a `createJob` rejection for a job that EXISTS and has not
|
|
96
|
+
* finished failed (its status is not DONE with an `errorResult`) and that names
|
|
97
|
+
* no fault of the caller: the SDK rejects with the job's `status.errors` even
|
|
98
|
+
* for warnings, and the job may still finish. The caller waits on that job
|
|
99
|
+
* under its id; it is never a new job and not yet an error. */
|
|
100
|
+
export declare function isUnfinishedJobError(err: unknown): boolean;
|
|
101
|
+
/** The location the job resource in a `createJob` rejection reports, if any. */
|
|
102
|
+
export declare function unfinishedJobLocation(err: unknown): string | undefined;
|
|
103
|
+
/** True when the JOB failed in a way a new job fixes: it reports
|
|
104
|
+
* `jobBackendError`, `jobInternalError` or `jobRateLimitExceeded` (Google's
|
|
105
|
+
* table says to retry with a new job id), or it finished failed with any other
|
|
106
|
+
* transient reason (a job's own `backendError` or `rateLimitExceeded`, which
|
|
107
|
+
* re-checking it would only report again). Only this, or a failure to create
|
|
108
|
+
* the job at all, justifies resubmitting. */
|
|
109
|
+
export declare function isJobLevelFailure(err: unknown, policy?: TransientPolicy): boolean;
|
|
110
|
+
/** True when a REQUEST failed in a way Google says to retry after a wait
|
|
111
|
+
* (`backendError`, `internalError`, `tableUnavailable`, `rateLimitExceeded`):
|
|
112
|
+
* when it concerns an existing job, ask again about that same job. A job-level
|
|
113
|
+
* failure is not a request failure (see `isJobLevelFailure`). */
|
|
114
|
+
export declare function isTransientRequestError(err: unknown, policy?: TransientPolicy): boolean;
|
|
89
115
|
export declare function isJobTimeoutError(err: unknown): boolean;
|
|
90
116
|
/** Classifies a streaming-insert failure. A `PartialFailureError` carries
|
|
91
117
|
* `errors[] = {row, errors: [{reason, message}]}`; a rate-limit/quota reason in
|
package/dist/bigquery/errors.js
CHANGED
|
@@ -30,6 +30,17 @@ export class RateLimitExceededError extends BigQueryReadError {
|
|
|
30
30
|
this.name = "RateLimitExceededError";
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
/** BigQuery failed on its own side (`jobBackendError`, `backendError`,
|
|
34
|
+
* `internalError`, `jobInternalError`, `tableUnavailable`; Google's message for the first reads
|
|
35
|
+
* "Retrying the job may solve the problem"). Transient, and the caller's
|
|
36
|
+
* request is not at fault, so it is distinct from BadQueryError even when
|
|
37
|
+
* Google reports it with HTTP 400. Retried like RateLimitExceededError. */
|
|
38
|
+
export class TransientBackendError extends BigQueryReadError {
|
|
39
|
+
constructor(message, cause) {
|
|
40
|
+
super(message, cause);
|
|
41
|
+
this.name = "TransientBackendError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
33
44
|
/** A dry-run estimate exceeded the caller-supplied byte budget — thrown
|
|
34
45
|
* before any billable query actually runs. */
|
|
35
46
|
export class DryRunBudgetExceededError extends BigQueryReadError {
|
|
@@ -97,7 +108,7 @@ export class InsertRowsPartialFailureError extends BigQueryReadError {
|
|
|
97
108
|
/** Reason codes the Google APIs client library attaches to a rejected job
|
|
98
109
|
* promise's `.errors[]` — see
|
|
99
110
|
* https://cloud.google.com/bigquery/docs/error-messages for the full list.
|
|
100
|
-
* Anything not in these
|
|
111
|
+
* Anything not in these sets falls through to the generic
|
|
101
112
|
* BigQueryReadError rather than being mis-classified. */
|
|
102
113
|
const PERMISSION_DENIED_REASONS = new Set([
|
|
103
114
|
"accessDenied",
|
|
@@ -110,34 +121,103 @@ const BAD_QUERY_REASONS = new Set([
|
|
|
110
121
|
"parseError",
|
|
111
122
|
"invalidQueryParameter",
|
|
112
123
|
]);
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
|
|
124
|
+
/** Reasons that classify as `RateLimitExceededError`. Classification is wider
|
|
125
|
+
* than what `runQuery` retries: Google gives no retry guidance for
|
|
126
|
+
* `quotaExceeded`, so `runQuery` and `estimateQueryBytes` never retry it. The
|
|
127
|
+
* load helpers retried it before SMS-293 and still do (see
|
|
128
|
+
* `TransientPolicy`). */
|
|
129
|
+
const RATE_LIMIT_REASONS = new Set([
|
|
130
|
+
"rateLimitExceeded",
|
|
131
|
+
"quotaExceeded",
|
|
132
|
+
"jobRateLimitExceeded",
|
|
133
|
+
]);
|
|
118
134
|
const RATE_LIMIT_REASON_TEXT = new RegExp([...RATE_LIMIT_REASONS].join("|"));
|
|
135
|
+
/** Reasons that say the JOB failed, which Google's error-messages table says to
|
|
136
|
+
* resubmit as a new job (new job id). */
|
|
137
|
+
const JOB_LEVEL_REASONS = new Set([
|
|
138
|
+
"jobBackendError",
|
|
139
|
+
"jobInternalError",
|
|
140
|
+
"jobRateLimitExceeded",
|
|
141
|
+
]);
|
|
142
|
+
/** Reasons BigQuery reports for a failed REQUEST (creating a job, checking a
|
|
143
|
+
* job's status, fetching its results). Against an existing job the answer is
|
|
144
|
+
* to wait and ask again about that same job, never to start another. */
|
|
145
|
+
const REQUEST_LEVEL_BACKEND_REASONS = new Set([
|
|
146
|
+
"backendError",
|
|
147
|
+
"internalError",
|
|
148
|
+
// Google's error-messages table (cloud.google.com/bigquery/docs/error-messages)
|
|
149
|
+
// says to retry it, following the internalError suggestions.
|
|
150
|
+
"tableUnavailable",
|
|
151
|
+
]);
|
|
152
|
+
/** Every reason that classifies as `TransientBackendError`. */
|
|
153
|
+
const BACKEND_ERROR_REASONS = new Set([
|
|
154
|
+
"jobBackendError",
|
|
155
|
+
"jobInternalError",
|
|
156
|
+
...REQUEST_LEVEL_BACKEND_REASONS,
|
|
157
|
+
]);
|
|
158
|
+
/** What `runQuery` retries on a request: rate limiting and backend failures,
|
|
159
|
+
* never `quotaExceeded`. */
|
|
160
|
+
const REQUEST_RETRY_REASONS = new Set([
|
|
161
|
+
...REQUEST_LEVEL_BACKEND_REASONS,
|
|
162
|
+
"rateLimitExceeded",
|
|
163
|
+
]);
|
|
164
|
+
const REQUEST_RETRY_REASON_TEXT = /rateLimitExceeded/;
|
|
119
165
|
/** BigQuery reports a `maximumBytesBilled` refusal as an `invalidQuery`-
|
|
120
166
|
* reasoned error whose message reads e.g. "Query exceeded limit for bytes
|
|
121
167
|
* billed: 123456789. Limit: 100000000." — text-matched (case-insensitively)
|
|
122
168
|
* since it shares its `reason` with every other bad-query case. */
|
|
123
169
|
const MAXIMUM_BYTES_BILLED_REASON_TEXT = /bytes billed/i;
|
|
170
|
+
function reasonsOf(err) {
|
|
171
|
+
if (!err || typeof err !== "object")
|
|
172
|
+
return [];
|
|
173
|
+
const entries = err.errors;
|
|
174
|
+
if (!Array.isArray(entries))
|
|
175
|
+
return [];
|
|
176
|
+
return entries.flatMap((cause) => cause && typeof cause.reason === "string" ? [cause.reason] : []);
|
|
177
|
+
}
|
|
178
|
+
/** True when the error list carries a fault of the caller (a bad query or
|
|
179
|
+
* missing permission). A caller fault wins over a transient reason listed
|
|
180
|
+
* beside it: resubmitting the same request cannot fix it. */
|
|
181
|
+
function hasCallerFault(err) {
|
|
182
|
+
return reasonsOf(err).some((reason) => BAD_QUERY_REASONS.has(reason) || PERMISSION_DENIED_REASONS.has(reason));
|
|
183
|
+
}
|
|
184
|
+
/** The structured `errors[]` entry that carries a caller fault. */
|
|
185
|
+
function callerFaultCause(apiErr) {
|
|
186
|
+
return apiErr?.errors?.find((cause) => cause.reason !== undefined &&
|
|
187
|
+
(BAD_QUERY_REASONS.has(cause.reason) ||
|
|
188
|
+
PERMISSION_DENIED_REASONS.has(cause.reason)));
|
|
189
|
+
}
|
|
124
190
|
/** The structured `errors[]` entry that carries a rate-limit reason, wherever it
|
|
125
191
|
* sits in the list — so a rate limit reported as a later entry is both detected
|
|
126
192
|
* and described by its own message, not an unrelated sibling's. */
|
|
127
193
|
function rateLimitCause(apiErr) {
|
|
128
194
|
return apiErr?.errors?.find((cause) => cause.reason !== undefined && RATE_LIMIT_REASONS.has(cause.reason));
|
|
129
195
|
}
|
|
196
|
+
/** The structured `errors[]` entry that carries a backend-failure reason. */
|
|
197
|
+
function backendCause(apiErr) {
|
|
198
|
+
return apiErr?.errors?.find((cause) => cause.reason !== undefined && BACKEND_ERROR_REASONS.has(cause.reason));
|
|
199
|
+
}
|
|
200
|
+
/** True when BigQuery reports it failed on its own side: a structured
|
|
201
|
+
* `errors[].reason` in BACKEND_ERROR_REASONS, with no caller fault beside it. */
|
|
202
|
+
function isBackendFailure(err) {
|
|
203
|
+
if (err instanceof TransientBackendError)
|
|
204
|
+
return true;
|
|
205
|
+
if (!err || typeof err !== "object" || hasCallerFault(err))
|
|
206
|
+
return false;
|
|
207
|
+
return backendCause(err) !== undefined;
|
|
208
|
+
}
|
|
130
209
|
/**
|
|
131
210
|
* The one definition of "BigQuery rate-limited this call", shared by
|
|
132
|
-
* `classifyBigQueryError` and
|
|
133
|
-
*
|
|
211
|
+
* `classifyBigQueryError` and the retry predicates so that what gets retried
|
|
212
|
+
* and how a retry-exhausted failure is reported can never disagree.
|
|
134
213
|
* True for any structured `errors[].reason` in RATE_LIMIT_REASONS or, for a raw
|
|
135
|
-
* REST error with no `errors[]`, that reason text in its `message
|
|
214
|
+
* REST error with no `errors[]`, that reason text in its `message`; never when
|
|
215
|
+
* a caller fault is listed beside it.
|
|
136
216
|
*/
|
|
137
217
|
function isRateLimited(err) {
|
|
138
218
|
if (err instanceof RateLimitExceededError)
|
|
139
219
|
return true;
|
|
140
|
-
if (!err || typeof err !== "object")
|
|
220
|
+
if (!err || typeof err !== "object" || hasCallerFault(err))
|
|
141
221
|
return false;
|
|
142
222
|
const apiErr = err;
|
|
143
223
|
if (rateLimitCause(apiErr))
|
|
@@ -155,9 +235,13 @@ export function classifyBigQueryError(err) {
|
|
|
155
235
|
if (err instanceof BigQueryReadError)
|
|
156
236
|
return err;
|
|
157
237
|
const apiErr = err;
|
|
158
|
-
// The entry that explains the classification: the
|
|
159
|
-
//
|
|
160
|
-
|
|
238
|
+
// The entry that explains the classification: the caller fault when one is
|
|
239
|
+
// listed (it outranks a transient reason beside it), else the rate-limit or
|
|
240
|
+
// backend cause, else the first reported error.
|
|
241
|
+
const detail = callerFaultCause(apiErr) ??
|
|
242
|
+
rateLimitCause(apiErr) ??
|
|
243
|
+
backendCause(apiErr) ??
|
|
244
|
+
apiErr?.errors?.[0];
|
|
161
245
|
const reason = detail?.reason;
|
|
162
246
|
const message = detail?.message ??
|
|
163
247
|
apiErr?.message ??
|
|
@@ -165,6 +249,9 @@ export function classifyBigQueryError(err) {
|
|
|
165
249
|
if (isRateLimited(err)) {
|
|
166
250
|
return new RateLimitExceededError(message, err);
|
|
167
251
|
}
|
|
252
|
+
if (isBackendFailure(err)) {
|
|
253
|
+
return new TransientBackendError(message, err);
|
|
254
|
+
}
|
|
168
255
|
if (reason && PERMISSION_DENIED_REASONS.has(reason)) {
|
|
169
256
|
return new PermissionDeniedError(message, err);
|
|
170
257
|
}
|
|
@@ -182,15 +269,86 @@ export function classifyBigQueryError(err) {
|
|
|
182
269
|
}
|
|
183
270
|
return new BigQueryReadError(message, err);
|
|
184
271
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
272
|
+
function retryReasons(policy) {
|
|
273
|
+
return policy?.quota
|
|
274
|
+
? new Set([...REQUEST_RETRY_REASONS, "quotaExceeded"])
|
|
275
|
+
: REQUEST_RETRY_REASONS;
|
|
276
|
+
}
|
|
277
|
+
/** An error as the client library threw it: an already-classified one is final. */
|
|
278
|
+
function isRawError(err) {
|
|
279
|
+
return (!!err && typeof err === "object" && !(err instanceof BigQueryReadError));
|
|
280
|
+
}
|
|
281
|
+
/** The job resource a `BigQuery#createJob` rejection carries as `response`: the
|
|
282
|
+
* SDK builds that rejection from `status.errors` of the job it just created,
|
|
283
|
+
* and Google says `status.errors` does not by itself mean the job failed (only
|
|
284
|
+
* `status.errorResult` on a DONE job does). `Job#poll_` rejects only for an
|
|
285
|
+
* `errorResult`, and its error carries no `response`. */
|
|
286
|
+
function createdJobStatus(err) {
|
|
287
|
+
const response = err.response;
|
|
288
|
+
const status = response?.status;
|
|
289
|
+
return status && typeof status === "object" ? status : undefined;
|
|
290
|
+
}
|
|
291
|
+
/** True when the error comes from a job that exists and has NOT finished failed:
|
|
292
|
+
* its status is not DONE with an `errorResult`. A new job id would run it twice. */
|
|
293
|
+
function isFromUnfinishedJob(err) {
|
|
294
|
+
const status = createdJobStatus(err);
|
|
295
|
+
return (status !== undefined && !(status.state === "DONE" && status.errorResult));
|
|
296
|
+
}
|
|
297
|
+
/** True when `err` is a `createJob` rejection for a job that EXISTS and has not
|
|
298
|
+
* finished failed (its status is not DONE with an `errorResult`) and that names
|
|
299
|
+
* no fault of the caller: the SDK rejects with the job's `status.errors` even
|
|
300
|
+
* for warnings, and the job may still finish. The caller waits on that job
|
|
301
|
+
* under its id; it is never a new job and not yet an error. */
|
|
302
|
+
export function isUnfinishedJobError(err) {
|
|
303
|
+
return isRawError(err) && isFromUnfinishedJob(err) && !hasCallerFault(err);
|
|
304
|
+
}
|
|
305
|
+
/** The location the job resource in a `createJob` rejection reports, if any. */
|
|
306
|
+
export function unfinishedJobLocation(err) {
|
|
307
|
+
const reference = err?.response?.jobReference;
|
|
308
|
+
return typeof reference?.location === "string"
|
|
309
|
+
? reference.location
|
|
310
|
+
: undefined;
|
|
311
|
+
}
|
|
312
|
+
/** A failure the JOB itself reports is an error with structured reasons, no HTTP
|
|
313
|
+
* `code` (a failed request always has one). The caller has already excluded a
|
|
314
|
+
* job that has not finished failed (`isFromUnfinishedJob`). */
|
|
315
|
+
function isReportedByJob(err) {
|
|
316
|
+
return (typeof err.code !== "number" &&
|
|
317
|
+
reasonsOf(err).length > 0);
|
|
318
|
+
}
|
|
319
|
+
/** True when the JOB failed in a way a new job fixes: it reports
|
|
320
|
+
* `jobBackendError`, `jobInternalError` or `jobRateLimitExceeded` (Google's
|
|
321
|
+
* table says to retry with a new job id), or it finished failed with any other
|
|
322
|
+
* transient reason (a job's own `backendError` or `rateLimitExceeded`, which
|
|
323
|
+
* re-checking it would only report again). Only this, or a failure to create
|
|
324
|
+
* the job at all, justifies resubmitting. */
|
|
325
|
+
export function isJobLevelFailure(err, policy) {
|
|
326
|
+
if (!isRawError(err) || hasCallerFault(err) || isFromUnfinishedJob(err)) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
const reasons = reasonsOf(err);
|
|
330
|
+
if (reasons.some((reason) => JOB_LEVEL_REASONS.has(reason)))
|
|
331
|
+
return true;
|
|
332
|
+
const retryable = retryReasons(policy);
|
|
333
|
+
return (isReportedByJob(err) && reasons.some((reason) => retryable.has(reason)));
|
|
334
|
+
}
|
|
335
|
+
/** True when a REQUEST failed in a way Google says to retry after a wait
|
|
336
|
+
* (`backendError`, `internalError`, `tableUnavailable`, `rateLimitExceeded`):
|
|
337
|
+
* when it concerns an existing job, ask again about that same job. A job-level
|
|
338
|
+
* failure is not a request failure (see `isJobLevelFailure`). */
|
|
339
|
+
export function isTransientRequestError(err, policy) {
|
|
340
|
+
if (!isRawError(err) || hasCallerFault(err))
|
|
341
|
+
return false;
|
|
342
|
+
if (isJobLevelFailure(err, policy))
|
|
343
|
+
return false;
|
|
344
|
+
const reasons = reasonsOf(err);
|
|
345
|
+
const retryable = retryReasons(policy);
|
|
346
|
+
if (reasons.length > 0) {
|
|
347
|
+
return reasons.some((reason) => retryable.has(reason));
|
|
348
|
+
}
|
|
349
|
+
const message = err.message;
|
|
350
|
+
return (typeof message === "string" &&
|
|
351
|
+
(policy?.quota ? RATE_LIMIT_REASON_TEXT : REQUEST_RETRY_REASON_TEXT).test(message));
|
|
194
352
|
}
|
|
195
353
|
/** BigQuery reports a `jobTimeoutMs`-stopped job as an `errorResult`/`errors[]`
|
|
196
354
|
* entry with `reason: "stopped"` whose message names the timeout (e.g.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/bigquery/errors.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAGxB;IAFlB,YACE,OAAe,EACC,KAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,UAAK,GAAL,KAAK,CAAU;QAG/B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,+DAA+D;AAC/D,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAClD,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,2EAA2E;AAC3E,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAC1D,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,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EAAE,MAAM,CAAC;IAC7D,MAAM,SAAS,GACb,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QACtB,OAAO,CAAC,MAAM,GAAG,CAAC;QAClB,OAAO,CAAC,KAAK,CACX,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC;YACD,OAAO,CAAC,KAAK,QAAQ;YACrB,KAAK,CAAC,OAAO,CAAE,CAAoB,CAAC,MAAM,CAAC,CAC9C,CAAC;IACJ,IAAI,CAAC,SAAS;QAAE,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,OAA2B,CAAC;IAC9C,MAAM,OAAO,GAAG,SAAS;SACtB,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;SACxB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3E,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,sBAAsB,CAC/B,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EACvC,GAAG,CACJ,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,6BAA6B,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,uBAAuB,CAAC,GAAY;IAClD,MAAM,OAAO,GAAI,GAAoC,EAAE,OAAO,CAAC;IAC/D,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAChF,CAAC"}
|
package/dist/bigquery/index.d.ts
CHANGED
|
@@ -46,10 +46,11 @@ export { runQuery, runQueryAllPages, estimateQueryBytes } from "./query.js";
|
|
|
46
46
|
export { extractTableToGCS, getExtractJobStatus, waitForExtractJob, } from "./extract.js";
|
|
47
47
|
export { loadFromUrisWithRetry, loadRowsWithRetry } from "./load.js";
|
|
48
48
|
export type { LoadFromUrisOptions, LoadJobOptions, LoadRowSource, LoadRowsOptions, LoadRowsResult, } from "./load.js";
|
|
49
|
+
export type { RetryOptions } from "./retry.js";
|
|
49
50
|
export { buildJobLabels, sanitizeLabelValue } from "./labels.js";
|
|
50
51
|
export { insertRows } from "./insert.js";
|
|
51
52
|
export type { InsertRowsOptions } from "./insert.js";
|
|
52
53
|
export { unwrapBigQueryCount, unwrapBigQueryRow, unwrapBigQueryValue, } from "./values.js";
|
|
53
|
-
export { BadQueryError, BigQueryReadError, DryRunBudgetExceededError, InsertRowsPartialFailureError, JobTimeoutError, MalformedResultSchemaError, MaximumBytesBilledExceededError, PermissionDeniedError, RateLimitExceededError,
|
|
54
|
+
export { BadQueryError, BigQueryReadError, DryRunBudgetExceededError, InsertRowsPartialFailureError, JobTimeoutError, MalformedResultSchemaError, MaximumBytesBilledExceededError, PermissionDeniedError, RateLimitExceededError, TransientBackendError, classifyBigQueryError, } from "./errors.js";
|
|
54
55
|
export type { InsertRowError } from "./errors.js";
|
|
55
56
|
export type { BigQueryApiErrorDetail, BigQueryCreateQueryJobOptions, BigQueryDatasetLike, BigQueryExtractOptions, BigQueryInsertOptions, BigQueryJobLike, BigQueryJobMetadata, BigQueryLike, BigQueryLoadOptions, BigQueryLoadJobLike, BigQueryNextQuery, BigQueryParamTypes, BigQueryParamTypeStruct, BigQueryQueryResultsOptions, BigQueryRawSchema, BigQueryRawSchemaField, BigQueryResultSchemaField, BigQuerySchemaField, BigQueryTableLike, BigQueryTableReference, DryRunEstimate, EstimateQueryBytesOptions, ExtractJobHandle, ExtractJobState, ExtractJobStatus, ExtractTableToGCSInput, GcsFileLike, JobLabelInput, QueryPage, RunQueryOptions, WaitForExtractJobOptions, } from "./types.js";
|
package/dist/bigquery/index.js
CHANGED
|
@@ -47,5 +47,5 @@ export { loadFromUrisWithRetry, loadRowsWithRetry } from "./load.js";
|
|
|
47
47
|
export { buildJobLabels, sanitizeLabelValue } from "./labels.js";
|
|
48
48
|
export { insertRows } from "./insert.js";
|
|
49
49
|
export { unwrapBigQueryCount, unwrapBigQueryRow, unwrapBigQueryValue, } from "./values.js";
|
|
50
|
-
export { BadQueryError, BigQueryReadError, DryRunBudgetExceededError, InsertRowsPartialFailureError, JobTimeoutError, MalformedResultSchemaError, MaximumBytesBilledExceededError, PermissionDeniedError, RateLimitExceededError,
|
|
50
|
+
export { BadQueryError, BigQueryReadError, DryRunBudgetExceededError, InsertRowsPartialFailureError, JobTimeoutError, MalformedResultSchemaError, MaximumBytesBilledExceededError, PermissionDeniedError, RateLimitExceededError, TransientBackendError, classifyBigQueryError, } from "./errors.js";
|
|
51
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bigquery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAMvD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bigquery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAMvD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAWrE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,eAAe,EACf,0BAA0B,EAC1B,+BAA+B,EAC/B,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BigQueryJobLike, BigQueryLike } from "./types.js";
|
|
2
|
+
/** The `{ location }` option `BigQueryLike#job` and `#dataset` take, or none when
|
|
3
|
+
* there is no location: the one place that shape is built. */
|
|
4
|
+
export declare function locationOption(location: string | undefined): {
|
|
5
|
+
location: string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
export declare class JobIdentity {
|
|
8
|
+
private current;
|
|
9
|
+
private submitted;
|
|
10
|
+
/** The location the job lives in: the one it was submitted with, replaced by
|
|
11
|
+
* the one BigQuery reports once the job is confirmed. BigQuery jobs are per
|
|
12
|
+
* location, so every lookup and re-wait must name it. */
|
|
13
|
+
location: string | undefined;
|
|
14
|
+
/** `requested` is the caller's job id; a random one is chosen when omitted.
|
|
15
|
+
* `location` is the one the job is submitted with. */
|
|
16
|
+
constructor(requested?: string, location?: string);
|
|
17
|
+
/** Takes the location BigQuery reports for the job, if it reports one. */
|
|
18
|
+
confirmLocation(reported: string | undefined): void;
|
|
19
|
+
/** The `{ location }` option for `BigQueryLike#job`, or none. */
|
|
20
|
+
get jobOptions(): {
|
|
21
|
+
location: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
get id(): string;
|
|
24
|
+
/** True once a submission under this id was sent: the job may exist even if
|
|
25
|
+
* that call failed, so look it up before submitting again. */
|
|
26
|
+
get mayExist(): boolean;
|
|
27
|
+
/** Marks that a submission under this id is about to be sent. */
|
|
28
|
+
markSubmitted(): void;
|
|
29
|
+
/** The job reported a failure and is final: the next submission is a new job
|
|
30
|
+
* and gets a new id. */
|
|
31
|
+
renew(): void;
|
|
32
|
+
}
|
|
33
|
+
/** The job lookup answered 404: no job has that id. */
|
|
34
|
+
export declare function isJobNotFound(err: unknown): boolean;
|
|
35
|
+
/** Submitting a job answered 409: a job with that id already exists. */
|
|
36
|
+
export declare function isJobAlreadyExists(err: unknown): boolean;
|
|
37
|
+
/** A handle on the job `jobId` if BigQuery has it, or `undefined` if the lookup
|
|
38
|
+
* answers 404 (it was never created). Any other lookup failure is thrown. */
|
|
39
|
+
export declare function findJob(bq: BigQueryLike, jobId: string, location?: string): Promise<BigQueryJobLike | undefined>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The identity of one logical BigQuery job across the attempts of a retried
|
|
3
|
+
* call. Google says the outcome of `jobs.insert` is unclear after a
|
|
4
|
+
* `backendError`: the job may exist although the call failed. So the id is
|
|
5
|
+
* chosen ONCE and reused by every submission of that job, which makes a repeat
|
|
6
|
+
* either find the job (and wait on it) or fail with 409 (it exists). A new id is
|
|
7
|
+
* taken only when the job itself reported a failure, because that job is final.
|
|
8
|
+
*/
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
/** The `{ location }` option `BigQueryLike#job` and `#dataset` take, or none when
|
|
11
|
+
* there is no location: the one place that shape is built. */
|
|
12
|
+
export function locationOption(location) {
|
|
13
|
+
return location ? { location } : undefined;
|
|
14
|
+
}
|
|
15
|
+
export class JobIdentity {
|
|
16
|
+
current;
|
|
17
|
+
submitted = false;
|
|
18
|
+
/** The location the job lives in: the one it was submitted with, replaced by
|
|
19
|
+
* the one BigQuery reports once the job is confirmed. BigQuery jobs are per
|
|
20
|
+
* location, so every lookup and re-wait must name it. */
|
|
21
|
+
location;
|
|
22
|
+
/** `requested` is the caller's job id; a random one is chosen when omitted.
|
|
23
|
+
* `location` is the one the job is submitted with. */
|
|
24
|
+
constructor(requested, location) {
|
|
25
|
+
this.current = requested ?? randomUUID();
|
|
26
|
+
this.location = location;
|
|
27
|
+
}
|
|
28
|
+
/** Takes the location BigQuery reports for the job, if it reports one. */
|
|
29
|
+
confirmLocation(reported) {
|
|
30
|
+
if (reported)
|
|
31
|
+
this.location = reported;
|
|
32
|
+
}
|
|
33
|
+
/** The `{ location }` option for `BigQueryLike#job`, or none. */
|
|
34
|
+
get jobOptions() {
|
|
35
|
+
return locationOption(this.location);
|
|
36
|
+
}
|
|
37
|
+
get id() {
|
|
38
|
+
return this.current;
|
|
39
|
+
}
|
|
40
|
+
/** True once a submission under this id was sent: the job may exist even if
|
|
41
|
+
* that call failed, so look it up before submitting again. */
|
|
42
|
+
get mayExist() {
|
|
43
|
+
return this.submitted;
|
|
44
|
+
}
|
|
45
|
+
/** Marks that a submission under this id is about to be sent. */
|
|
46
|
+
markSubmitted() {
|
|
47
|
+
this.submitted = true;
|
|
48
|
+
}
|
|
49
|
+
/** The job reported a failure and is final: the next submission is a new job
|
|
50
|
+
* and gets a new id. */
|
|
51
|
+
renew() {
|
|
52
|
+
this.current = randomUUID();
|
|
53
|
+
this.submitted = false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function httpCode(err) {
|
|
57
|
+
return err && typeof err === "object"
|
|
58
|
+
? err.code
|
|
59
|
+
: undefined;
|
|
60
|
+
}
|
|
61
|
+
/** The job lookup answered 404: no job has that id. */
|
|
62
|
+
export function isJobNotFound(err) {
|
|
63
|
+
return httpCode(err) === 404;
|
|
64
|
+
}
|
|
65
|
+
/** Submitting a job answered 409: a job with that id already exists. */
|
|
66
|
+
export function isJobAlreadyExists(err) {
|
|
67
|
+
return httpCode(err) === 409;
|
|
68
|
+
}
|
|
69
|
+
/** A handle on the job `jobId` if BigQuery has it, or `undefined` if the lookup
|
|
70
|
+
* answers 404 (it was never created). Any other lookup failure is thrown. */
|
|
71
|
+
export async function findJob(bq, jobId, location) {
|
|
72
|
+
const handle = bq.job(jobId, locationOption(location));
|
|
73
|
+
try {
|
|
74
|
+
await handle.getMetadata();
|
|
75
|
+
return handle;
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
if (isJobNotFound(err))
|
|
79
|
+
return undefined;
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=jobIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobIdentity.js","sourceRoot":"","sources":["../../src/bigquery/jobIdentity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC;+DAC+D;AAC/D,MAAM,UAAU,cAAc,CAC5B,QAA4B;IAE5B,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC;AAED,MAAM,OAAO,WAAW;IACd,OAAO,CAAS;IAChB,SAAS,GAAG,KAAK,CAAC;IAE1B;;8DAE0D;IAC1D,QAAQ,CAAqB;IAE7B;2DACuD;IACvD,YAAY,SAAkB,EAAE,QAAiB;QAC/C,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,UAAU,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,0EAA0E;IAC1E,eAAe,CAAC,QAA4B;QAC1C,IAAI,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACzC,CAAC;IAED,iEAAiE;IACjE,IAAI,UAAU;QACZ,OAAO,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,I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js";
|
|
1
2
|
import type { BigQueryLike, BigQueryLoadOptions } from "./types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Opens the rows for one load attempt. Called once per attempt: a retry after
|
|
4
|
-
* a
|
|
5
|
+
* a transient error re-uploads everything, so it calls this again and must
|
|
5
6
|
* get the same rows. That is why the source is a function and not an
|
|
6
7
|
* iterable — a generator object can only be consumed once, so a retry handed
|
|
7
8
|
* the same one would silently load nothing.
|
|
8
9
|
*/
|
|
9
10
|
export type LoadRowSource<T extends object> = () => AsyncIterable<T> | Iterable<T>;
|
|
10
|
-
export interface LoadJobOptions extends BigQueryLoadOptions {
|
|
11
|
+
export interface LoadJobOptions extends BigQueryLoadOptions, RetryOptions {
|
|
11
12
|
datasetId: string;
|
|
12
13
|
tableId: string;
|
|
13
|
-
/** Total attempts before giving up, including the first. Default 5. */
|
|
14
|
-
attempts?: number;
|
|
15
|
-
/** Delay before the first retry; doubles every subsequent retry. Default 1000ms. */
|
|
16
|
-
initialDelayMs?: number;
|
|
17
|
-
/** Injectable for tests — real code always uses a real timer. */
|
|
18
|
-
sleep?: (ms: number) => Promise<void>;
|
|
19
14
|
}
|
|
20
15
|
export interface LoadRowsOptions extends LoadJobOptions {
|
|
21
16
|
/** Target size of each NDJSON chunk written to the load job, in bytes. The
|
|
@@ -34,11 +29,13 @@ export interface LoadRowsResult {
|
|
|
34
29
|
}
|
|
35
30
|
/**
|
|
36
31
|
* Streams the rows `source` yields into `datasetId.tableId` in one load job,
|
|
37
|
-
* retrying with exponential backoff ONLY
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* throw from the source, etc.) is classified and rethrown on the
|
|
41
|
-
* attempt. Each
|
|
32
|
+
* retrying with exponential backoff ONLY for BigQuery's transient errors, and
|
|
33
|
+
* never loading the rows twice: see `loadWithRetry` for when the same job is
|
|
34
|
+
* waited on and when a new one is submitted. Any other error (bad schema, auth
|
|
35
|
+
* failure, a throw from the source, etc.) is classified and rethrown on the
|
|
36
|
+
* first attempt. Each submission calls `source` afresh — see `LoadRowSource`.
|
|
37
|
+
* \`options.jobId\` is the id the load job is submitted under (random when
|
|
38
|
+
* omitted).
|
|
42
39
|
*
|
|
43
40
|
* Pass `writeDisposition: "WRITE_TRUNCATE"` for a full-refresh reload; omit it
|
|
44
41
|
* for an append load.
|
|
@@ -49,7 +46,7 @@ export declare function loadRowsWithRetry<T extends object>(bq: BigQueryLike, op
|
|
|
49
46
|
* gzip-compressed or not) into `datasetId.tableId` in ONE load job, which
|
|
50
47
|
* BigQuery runs reading the files in parallel. Nothing is parsed or
|
|
51
48
|
* re-serialised here. Retry and error classes are those of
|
|
52
|
-
* `loadRowsWithRetry
|
|
49
|
+
* `loadRowsWithRetry`.
|
|
53
50
|
*
|
|
54
51
|
* `rowCount` is what BigQuery reports the job wrote
|
|
55
52
|
* (`statistics.load.outputRows`), never a count taken locally; a job that
|