MCPcopy Create free account
hub / github.com/dataform-co/dataform / executeTask

Method executeTask

cli/api/commands/run.ts:412–468  ·  view source on GitHub ↗
(
    client: dbadapters.IDbClient,
    task: dataform.IExecutionTask,
    parentAction: dataform.IActionResult,
    options: { bigquery?: dataform.IBigQueryOptions & IBigQueryExecutionOptions }
  )

Source from the content-addressed store, hash-verified

410 }
411
412 private async executeTask(
413 client: dbadapters.IDbClient,
414 task: dataform.IExecutionTask,
415 parentAction: dataform.IActionResult,
416 options: { bigquery?: dataform.IBigQueryOptions & IBigQueryExecutionOptions }
417 ): Promise<dataform.TaskResult.ExecutionStatus> {
418 const timer = Timer.start();
419 const taskResult: dataform.ITaskResult = {
420 status: dataform.TaskResult.ExecutionStatus.RUNNING,
421 timing: timer.current(),
422 metadata: {}
423 };
424 parentAction.tasks.push(taskResult);
425 this.notifyListeners();
426 if (options.bigquery?.dryRun && task.type === "assertion") {
427 taskResult.status = dataform.TaskResult.ExecutionStatus.SUCCESSFUL;
428 }
429 else {
430 try {
431 // Retry this function a given number of times, configurable by user
432 const { rows, metadata } = await retry(
433 () =>
434 client.execute(task.statement, {
435 onCancel: handleCancel => this.eEmitter.on(CANCEL_EVENT, handleCancel),
436 rowLimit: 1,
437 bigquery: options.bigquery
438 }),
439 task.type === "operation" ? 1 : options.bigquery.actionRetryLimit + 1 || 1
440 );
441 taskResult.metadata = metadata;
442 if (task.type === "assertion") {
443 // We expect that an assertion query returns 1 row, with 1 field that is the row count.
444 // We don't really care what that field/column is called.
445 const rowCount = rows[0]?.[Object.keys(rows[0])[0]];
446 if (rowCount > 0) {
447 throw new Error(`Assertion failed: query returned ${rowCount} row(s).`);
448 }
449 }
450 taskResult.status = dataform.TaskResult.ExecutionStatus.SUCCESSFUL;
451 } catch (e) {
452 taskResult.status = this.cancelled
453 ? dataform.TaskResult.ExecutionStatus.CANCELLED
454 : dataform.TaskResult.ExecutionStatus.FAILED;
455 taskResult.errorMessage = `${this.graph.projectConfig.warehouse} error: ${e.message}`;
456 if (e.metadata?.bigquery?.jobId) {
457 taskResult.metadata = {
458 bigquery: {
459 jobId: e.metadata.bigquery.jobId
460 }
461 };
462 }
463 }
464 }
465 taskResult.timing = timer.end();
466 this.notifyListeners();
467 return taskResult.status;
468 }
469}

Callers 1

executeActionMethod · 0.95

Calls 7

notifyListenersMethod · 0.95
retryFunction · 0.90
startMethod · 0.80
currentMethod · 0.80
endMethod · 0.80
executeMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected