File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
src/dbt/adapters/bigquery Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ kind : Fixes
2+ body : BigFrames notebook execution when using a service account with oauth
3+ time : 2025-09-01T10:00:53.749318+02:00
4+ custom :
5+ Author : jspenmar
6+ Issue : " 1231"
Original file line number Diff line number Diff line change 4747# Time interval in seconds between successive polling attempts to check the
4848# notebook job's status in BigFrames mode.
4949_COLAB_POLL_INTERVAL = 30
50+ # Suffix used by service accounts.
51+ _SERVICE_ACCOUNT_SUFFIX = "iam.gserviceaccount.com"
5052
5153
5254class _BigQueryPythonHelper (PythonJobHelper ):
@@ -332,12 +334,19 @@ def _config_notebook_job(
332334 url = "https://www.googleapis.com/oauth2/v2/userinfo" ,
333335 headers = {"Authorization" : f"Bearer { self ._GoogleCredentials .token } " },
334336 )
337+
335338 if response .status != 200 :
336339 raise DbtRuntimeError (
337340 f"Failed to retrieve user info. Status: { response .status } , Body: { response .data } "
338341 )
339342 if user_email := json .loads (response .data ).get ("email" ):
340- notebook_execution_job .execution_user = user_email
343+ # In services such as Cloud Composer and Cloud Run, the authenticated user
344+ # is a service account with associated Application Default Credentials.
345+ # This does not require service account impersonation.
346+ if user_email and user_email .endswith (_SERVICE_ACCOUNT_SUFFIX ):
347+ notebook_execution_job .service_account = user_email
348+ else :
349+ notebook_execution_job .execution_user = user_email
341350 else :
342351 raise DbtRuntimeError (
343352 "Authorization request to get user failed to return an email."
You can’t perform that action at this time.
0 commit comments