From c36c90257b7699fa79d516b6632b84c5f50fcc2e Mon Sep 17 00:00:00 2001 From: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> Date: Fri, 7 Jul 2023 08:08:54 -0600 Subject: [PATCH] Enable single-line `private_key` for BigQuery Service Account JSON Authentication (#625) * Enable single-line `private_key` for BigQuery Service Account JSON Authentication * Use post-init processing to handle single-line `private_key`s --- .changes/unreleased/Fixes-20230322-150627.yaml | 6 ++++++ dbt/adapters/bigquery/connections.py | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 .changes/unreleased/Fixes-20230322-150627.yaml diff --git a/.changes/unreleased/Fixes-20230322-150627.yaml b/.changes/unreleased/Fixes-20230322-150627.yaml new file mode 100644 index 000000000..90ef354f9 --- /dev/null +++ b/.changes/unreleased/Fixes-20230322-150627.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Enable single-line `private_key` for BigQuery Service Account JSON Authentication +time: 2023-03-22T15:06:27.761416-06:00 +custom: + Author: dbeatty10 + Issue: "7164" diff --git a/dbt/adapters/bigquery/connections.py b/dbt/adapters/bigquery/connections.py index 109e63c64..06da1ff90 100644 --- a/dbt/adapters/bigquery/connections.py +++ b/dbt/adapters/bigquery/connections.py @@ -158,6 +158,12 @@ class BigQueryCredentials(Credentials): "timeout_seconds": "job_execution_timeout_seconds", } + def __post_init__(self): + if self.keyfile_json and "private_key" in self.keyfile_json: + self.keyfile_json["private_key"] = self.keyfile_json["private_key"].replace( + "\\n", "\n" + ) + @property def type(self): return "bigquery"