Skip to content

Commit 20f183f

Browse files
committed
Add run id also to query tag enum an pass it thru QueryTags
1 parent 528c622 commit 20f183f

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/Connection/Bigquery/BigQueryClientWrapper.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BigQueryClientWrapper extends BigQueryClient
2828
*/
2929
public function __construct(
3030
array $config = [],
31-
readonly string $runId = '',
31+
string $runId = '',
3232
array $queryTags = [],
3333
BackOffPolicyInterface|null $backOffPolicy = null,
3434
) {
@@ -43,6 +43,9 @@ public function __construct(
4343
$this->backOffPolicy = $backOffPolicy;
4444
}
4545

46+
if ($runId !== '') {
47+
$queryTags[QueryTagKey::RUN_ID->value] = $runId;
48+
}
4649
$this->queryTags = new QueryTags($queryTags);
4750
}
4851

@@ -51,17 +54,8 @@ public function __construct(
5154
*/
5255
public function runQuery(JobConfigurationInterface $query, array $options = []): QueryResults
5356
{
54-
$allQueryTags = [];
55-
if ($this->runId !== '') {
56-
$allQueryTags['run_id'] = $this->runId;
57-
}
58-
59-
if ($this->queryTags->isEmpty() === false) {
60-
$allQueryTags = array_merge($allQueryTags, $this->queryTags->toArray());
61-
}
62-
63-
if (count($allQueryTags) !== 0 && method_exists($query, 'labels')) {
64-
$query = $query->labels($allQueryTags);
57+
if (count($this->queryTags->toArray()) !== 0 && method_exists($query, 'labels')) {
58+
$query = $query->labels($this->queryTags->toArray());
6559
}
6660

6761
return $this->runJob($query, $options)

src/Connection/Bigquery/QueryTagKey.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
enum QueryTagKey: string
1010
{
1111
case BRANCH_ID = 'branch_id';
12+
case RUN_ID = 'run_id';
1213

1314
/**
1415
* Validates if the given string is a valid tag key

0 commit comments

Comments
 (0)