@@ -128,6 +128,18 @@ def _verify_dml_stats_resource_properties(self, job, resource):
128
128
else :
129
129
assert job .dml_stats is None
130
130
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
+
131
143
def _verify_configuration_properties (self , job , configuration ):
132
144
if "dryRun" in configuration :
133
145
self .assertEqual (job .dry_run , configuration ["dryRun" ])
@@ -137,6 +149,7 @@ def _verify_configuration_properties(self, job, configuration):
137
149
def _verifyResourceProperties (self , job , resource ):
138
150
self ._verifyReadonlyResourceProperties (job , resource )
139
151
self ._verify_dml_stats_resource_properties (job , resource )
152
+ self ._verify_transaction_info_resource_properties (job , resource )
140
153
141
154
configuration = resource .get ("configuration" , {})
142
155
self ._verify_configuration_properties (job , configuration )
@@ -325,6 +338,22 @@ def test_from_api_repr_with_dml_stats(self):
325
338
self .assertIs (job ._client , client )
326
339
self ._verifyResourceProperties (job , RESOURCE )
327
340
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
+
328
357
def test_from_api_repr_w_properties (self ):
329
358
from google .cloud .bigquery .job import CreateDisposition
330
359
from google .cloud .bigquery .job import SchemaUpdateOption
0 commit comments