diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f2ef619c3..bb00917bcb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Added ability to snapshot hard-deleted records (opt-in with `invalidate_hard_deletes` config option). ([#249](https://github.com/fishtown-analytics/dbt/issues/249), [#2749](https://github.com/fishtown-analytics/dbt/pull/2749)) - Improved error messages for YAML selectors ([#2700](https://github.com/fishtown-analytics/dbt/issues/2700), [#2781](https://github.com/fishtown-analytics/dbt/pull/2781)) - Save manifest at the same time we save the run_results at the end of a run ([#2765](https://github.com/fishtown-analytics/dbt/issues/2765), [#2799](https://github.com/fishtown-analytics/dbt/pull/2799)) +- Added dbt_invocation_id for each BigQuery job to enable performance analysis ([#2808](https://github.com/fishtown-analytics/dbt/issues/2808), [#2809](https://github.com/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://github.com/fishtown-analytics/dbt/issues/2787), [#2791](https://github.com/fishtown-analytics/dbt/pull/2791)) diff --git a/plugins/bigquery/dbt/adapters/bigquery/connections.py b/plugins/bigquery/dbt/adapters/bigquery/connections.py index 5fb2857a043..c4b09eb2b48 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/connections.py +++ b/plugins/bigquery/dbt/adapters/bigquery/connections.py @@ -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 @@ -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: