Skip to content

Commit c9d4a51

Browse files
committed
Modified the createJob parameter to contain just job related information
1 parent d0260d3 commit c9d4a51

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

BigQuery/src/BigQueryClient.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,20 +437,27 @@ public function runQuery(JobConfigurationInterface $query, array $options = [])
437437

438438
$response = $this->connection->query($statelessArgs);
439439

440+
$jobId = $response['jobReference']['jobId'] ?? '';
441+
$jobInfo = ['jobReference' => $response['jobReference'] ?? []];
442+
if (isset($response['statistics'])) {
443+
$jobInfo['statistics'] = $response['statistics'];
444+
}
445+
440446
if ($response['jobComplete'] ?? false) {
441-
$jobId = $response['jobReference']['jobId'] ?? '';
447+
// This is to keep it consistent with the response from a non stateless query
448+
$jobInfo['status']['state'] = Job::DONE;
442449
return new QueryResults(
443450
$this->connection,
444451
$jobId,
445452
$this->projectId,
446453
$response,
447454
$this->mapper,
448-
$this->createJob($response, $jobId),
455+
$this->createJob($jobInfo, $jobId),
449456
$queryResultsOptions
450457
);
451458
}
452459

453-
$job = $this->createJob($response, $response['jobReference']['jobId']);
460+
$job = $this->createJob($jobInfo, $jobId);
454461
} else {
455462
$job = $this->startQuery($query, $options);
456463
}

BigQuery/src/Job.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Job
3333
use JobWaitTrait;
3434

3535
const MAX_RETRIES = PHP_INT_MAX;
36+
const DONE = 'DONE';
3637

3738
/**
3839
* @var ConnectionInterface Represents a connection to BigQuery.

0 commit comments

Comments
 (0)