Skip to content

Commit

Permalink
Don't make people set the same value in two variables (datacontract#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpraetorius authored Jun 5, 2024
1 parent 8d652df commit 23240fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ models:

| Environment Variable | Example | Description |
|----------------------------------------------|---------------------------|---------------------------------------------------------|
| `DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATH` | `~/service-access-key.json` | Service Access key as saved on key creation by BigQuery |
| `DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATH` | `~/service-access-key.json` | Service Access key as saved on key creation by BigQuery. If this environment variable isn't set, the cli tries to use `GOOGLE_APPLICATION_CREDENTIALS` as a fallback, so if you have that set for using their Python library anyway, it should work seamlessly. |



Expand Down
9 changes: 8 additions & 1 deletion datacontract/engines/soda/connections/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
# https://docs.soda.io/soda/connect-bigquery.html#authentication-methods
def to_bigquery_soda_configuration(server):
# with service account key, using an external json file

# check for our own environment variable first
account_info = os.getenv("DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATH")
if account_info is None:
# but as a fallback look for the default google one
account_info = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")

soda_configuration = {
f"data_source {server.type}": {
"type": "bigquery",
"account_info_json_path": os.getenv("DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATH"),
"account_info_json_path": account_info,
"auth_scopes": ["https://www.googleapis.com/auth/bigquery"],
"project_id": server.project,
"dataset": server.dataset,
Expand Down

0 comments on commit 23240fd

Please sign in to comment.