File tree 2 files changed +14
-3
lines changed
google/cloud/bigquery/job
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):
357
357
def transaction_info (self ) -> Optional [TransactionInfo ]:
358
358
"""Information of the multi-statement transaction if this job is part of one.
359
359
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
+
360
365
.. versionadded:: 2.24.0
361
366
"""
362
367
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):
1586
1586
query_job = Config .CLIENT .query (sql )
1587
1587
query_job .result ()
1588
1588
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 != ""
1592
1598
1593
1599
def test_dbapi_w_standard_sql_types (self ):
1594
1600
for sql , expected in helpers .STANDARD_SQL_EXAMPLES :
You can’t perform that action at this time.
0 commit comments