@@ -128,6 +128,18 @@ def _verify_dml_stats_resource_properties(self, job, resource):
128128 else :
129129 assert job .dml_stats is None
130130
131+ def _verify_transaction_info_resource_properties (self , job , resource ):
132+ resource_stats = resource .get ("statistics" , {})
133+
134+ if "transactionInfo" in resource_stats :
135+ resource_transaction_info = resource_stats ["transactionInfo" ]
136+ job_transaction_info = job .transaction_info
137+ assert job_transaction_info .transaction_id == resource_transaction_info .get (
138+ "transactionId"
139+ )
140+ else :
141+ assert job .transaction_info is None
142+
131143 def _verify_configuration_properties (self , job , configuration ):
132144 if "dryRun" in configuration :
133145 self .assertEqual (job .dry_run , configuration ["dryRun" ])
@@ -137,6 +149,7 @@ def _verify_configuration_properties(self, job, configuration):
137149 def _verifyResourceProperties (self , job , resource ):
138150 self ._verifyReadonlyResourceProperties (job , resource )
139151 self ._verify_dml_stats_resource_properties (job , resource )
152+ self ._verify_transaction_info_resource_properties (job , resource )
140153
141154 configuration = resource .get ("configuration" , {})
142155 self ._verify_configuration_properties (job , configuration )
@@ -325,6 +338,22 @@ def test_from_api_repr_with_dml_stats(self):
325338 self .assertIs (job ._client , client )
326339 self ._verifyResourceProperties (job , RESOURCE )
327340
341+ def test_from_api_repr_with_transaction_info (self ):
342+ self ._setUpConstants ()
343+ client = _make_client (project = self .PROJECT )
344+ RESOURCE = {
345+ "id" : self .JOB_ID ,
346+ "jobReference" : {"projectId" : self .PROJECT , "jobId" : self .JOB_ID },
347+ "configuration" : {"query" : {"query" : self .QUERY }},
348+ "statistics" : {"transactionInfo" : {"transactionId" : "1a2b-3c4d" }},
349+ }
350+ klass = self ._get_target_class ()
351+
352+ job = klass .from_api_repr (RESOURCE , client = client )
353+
354+ self .assertIs (job ._client , client )
355+ self ._verifyResourceProperties (job , RESOURCE )
356+
328357 def test_from_api_repr_w_properties (self ):
329358 from google .cloud .bigquery .job import CreateDisposition
330359 from google .cloud .bigquery .job import SchemaUpdateOption
0 commit comments