File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
google/cloud/bigquery/job Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,11 @@ def reservation_usage(self):
357357 def transaction_info (self ) -> Optional [TransactionInfo ]:
358358 """Information of the multi-statement transaction if this job is part of one.
359359
360+ Since a scripting query job can execute multiple transactions, this
361+ property is only expected on child jobs. Use the
362+ :meth:`google.cloud.bigquery.client.Client.list_jobs` method with the
363+ ``parent_job`` parameter to iterate over child jobs.
364+
360365 .. versionadded:: 2.24.0
361366 """
362367 info = self ._properties .get ("statistics" , {}).get ("transactionInfo" )
Original file line number Diff line number Diff line change @@ -1586,9 +1586,15 @@ def test_transaction_info(self):
15861586 query_job = Config .CLIENT .query (sql )
15871587 query_job .result ()
15881588
1589- # Transaction ID set by the server should be accessible
1590- assert query_job .transaction_info is not None
1591- assert query_job .transaction_info .transaction_id != ""
1589+ child_jobs = Config .CLIENT .list_jobs (parent_job = query_job )
1590+ begin_transaction_job = next (iter (child_jobs ))
1591+
1592+ # Transaction ID set by the server should be accessible on the child
1593+ # job responsible for `BEGIN TRANSACTION`. It is not expected to be
1594+ # present on the parent job itself.
1595+ # https://github.com/googleapis/python-bigquery/issues/975
1596+ assert begin_transaction_job .transaction_info is not None
1597+ assert begin_transaction_job .transaction_info .transaction_id != ""
15921598
15931599 def test_dbapi_w_standard_sql_types (self ):
15941600 for sql , expected in helpers .STANDARD_SQL_EXAMPLES :
You can’t perform that action at this time.
0 commit comments