Skip to content

Commit

Permalink
Merge pull request #2809 from mescanne/bigquery_invocation_id
Browse files Browse the repository at this point in the history
Add invocation_id to BigQuery jobs
  • Loading branch information
jtcohen6 authored Oct 7, 2020
2 parents 3f45abe + 9832822 commit 93168fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Added ability to snapshot hard-deleted records (opt-in with `invalidate_hard_deletes` config option). ([#249](https:/fishtown-analytics/dbt/issues/249), [#2749](https:/fishtown-analytics/dbt/pull/2749))
- Improved error messages for YAML selectors ([#2700](https:/fishtown-analytics/dbt/issues/2700), [#2781](https:/fishtown-analytics/dbt/pull/2781))
- Save manifest at the same time we save the run_results at the end of a run ([#2765](https:/fishtown-analytics/dbt/issues/2765), [#2799](https:/fishtown-analytics/dbt/pull/2799))
- Added dbt_invocation_id for each BigQuery job to enable performance analysis ([#2808](https:/fishtown-analytics/dbt/issues/2808), [#2809](https:/fishtown-analytics/dbt/pull/2809))

### Under the hood
- Added strategy-specific validation to improve the relevancy of compilation errors for the `timestamp` and `check` snapshot strategies. (([#2787](https:/fishtown-analytics/dbt/issues/2787), [#2791](https:/fishtown-analytics/dbt/pull/2791))
Expand Down
10 changes: 9 additions & 1 deletion plugins/bigquery/dbt/adapters/bigquery/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from dbt.utils import format_bytes, format_rows_number
from dbt.clients import agate_helper, gcloud
from dbt.tracking import active_user
from dbt.contracts.connection import ConnectionState
from dbt.exceptions import (
FailedToConnectException, RuntimeException, DatabaseException
Expand Down Expand Up @@ -249,7 +250,14 @@ def raw_execute(self, sql, fetch=False):

logger.debug('On {}: {}', conn.name, sql)

job_params = {'use_legacy_sql': False}
job_params = {
'use_legacy_sql': False,
}

if active_user:
job_params['labels'] = {
'dbt_invocation_id': active_user.invocation_id
}

priority = conn.credentials.priority
if priority == Priority.Batch:
Expand Down

0 comments on commit 93168fe

Please sign in to comment.