From 6e2d690cf43cc10a2f7980b95d49c2c30e872dfa Mon Sep 17 00:00:00 2001 From: Christophe Oudar Date: Fri, 5 May 2023 18:38:14 +0200 Subject: [PATCH] move job link logging just after the job submit --- .changes/unreleased/Features-20230505-184427.yaml | 6 ++++++ dbt/adapters/bigquery/connections.py | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Features-20230505-184427.yaml diff --git a/.changes/unreleased/Features-20230505-184427.yaml b/.changes/unreleased/Features-20230505-184427.yaml new file mode 100644 index 000000000..1267d02ab --- /dev/null +++ b/.changes/unreleased/Features-20230505-184427.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Move the BQ Job link after the job submission instead of job done +time: 2023-05-05T18:44:27.939038+02:00 +custom: + Author: Kayrnt + Issue: "696" diff --git a/dbt/adapters/bigquery/connections.py b/dbt/adapters/bigquery/connections.py index a561eb5b9..e42b37147 100644 --- a/dbt/adapters/bigquery/connections.py +++ b/dbt/adapters/bigquery/connections.py @@ -521,9 +521,6 @@ def execute( else: message = f"{code}" - if location is not None and job_id is not None and project_id is not None: - logger.debug(self._bq_job_link(location, project_id, job_id)) - response = BigQueryAdapterResponse( # type: ignore[call-arg] _message=message, rows_affected=num_rows, @@ -649,6 +646,16 @@ def _query_and_results( # Cannot reuse job_config if destination is set and ddl is used job_config = google.cloud.bigquery.QueryJobConfig(**job_params) query_job = client.query(query=sql, job_config=job_config, timeout=job_creation_timeout) + + if ( + query_job.location is not None + and query_job.job_id is not None + and query_job.project is not None + ): + logger.debug( + self._bq_job_link(query_job.location, query_job.project, query_job.job_id) + ) + iterator = query_job.result(timeout=job_execution_timeout) return query_job, iterator