@@ -44,6 +44,7 @@ public abstract class JobStatistics implements Serializable {
44
44
private final String parentJobId ;
45
45
private final ScriptStatistics scriptStatistics ;
46
46
private final List <ReservationUsage > reservationUsage ;
47
+ private final TransactionInfo transactionInfo ;
47
48
48
49
/** A Google BigQuery Copy Job statistics. */
49
50
public static class CopyStatistics extends JobStatistics {
@@ -1178,6 +1179,78 @@ static ReservationUsage fromPb(
1178
1179
}
1179
1180
}
1180
1181
1182
+ // TransactionInfo contains information about a multi-statement transaction that may have
1183
+ // associated with a job.
1184
+ public static class TransactionInfo {
1185
+
1186
+ // TransactionID is the system-generated identifier for the transaction.
1187
+ private final String transactionId ;
1188
+
1189
+ public static class Builder {
1190
+
1191
+ private String transactionId ;
1192
+
1193
+ private Builder () {};
1194
+
1195
+ Builder setTransactionId (String transactionId ) {
1196
+ this .transactionId = transactionId ;
1197
+ return this ;
1198
+ }
1199
+
1200
+ TransactionInfo build () {
1201
+ return new TransactionInfo (this );
1202
+ }
1203
+ }
1204
+
1205
+ private TransactionInfo (Builder builder ) {
1206
+ this .transactionId = builder .transactionId ;
1207
+ }
1208
+
1209
+ public String getTransactionId () {
1210
+ return transactionId ;
1211
+ }
1212
+
1213
+ static Builder newbuilder () {
1214
+ return new Builder ();
1215
+ }
1216
+
1217
+ ToStringHelper toStringHelper () {
1218
+ return MoreObjects .toStringHelper (this ).add ("transactionId" , transactionId );
1219
+ }
1220
+
1221
+ @ Override
1222
+ public String toString () {
1223
+ return toStringHelper ().toString ();
1224
+ }
1225
+
1226
+ @ Override
1227
+ public boolean equals (Object obj ) {
1228
+ return obj == this
1229
+ || obj != null
1230
+ && obj .getClass ().equals (TransactionInfo .class )
1231
+ && Objects .equals (toPb (), ((TransactionInfo ) obj ).toPb ());
1232
+ }
1233
+
1234
+ @ Override
1235
+ public int hashCode () {
1236
+ return Objects .hash (transactionId );
1237
+ }
1238
+
1239
+ com .google .api .services .bigquery .model .TransactionInfo toPb () {
1240
+ com .google .api .services .bigquery .model .TransactionInfo transactionInfo =
1241
+ new com .google .api .services .bigquery .model .TransactionInfo ();
1242
+ transactionInfo .setTransactionId (transactionId );
1243
+ return transactionInfo ;
1244
+ }
1245
+
1246
+ static TransactionInfo fromPb (
1247
+ com .google .api .services .bigquery .model .TransactionInfo transactionInfo ) {
1248
+ Builder builder = newbuilder ();
1249
+ builder .setTransactionId (transactionInfo .getTransactionId ());
1250
+ return builder .build ();
1251
+ }
1252
+ }
1253
+
1181
1254
abstract static class Builder <T extends JobStatistics , B extends Builder <T , B >> {
1182
1255
1183
1256
private Long creationTime ;
@@ -1187,6 +1260,7 @@ abstract static class Builder<T extends JobStatistics, B extends Builder<T, B>>
1187
1260
private String parentJobId ;
1188
1261
private ScriptStatistics scriptStatistics ;
1189
1262
private List <ReservationUsage > reservationUsage ;
1263
+ private TransactionInfo transactionInfo ;
1190
1264
1191
1265
protected Builder () {}
1192
1266
@@ -1203,6 +1277,9 @@ protected Builder(com.google.api.services.bigquery.model.JobStatistics statistic
1203
1277
this .reservationUsage =
1204
1278
Lists .transform (statisticsPb .getReservationUsage (), ReservationUsage .FROM_PB_FUNCTION );
1205
1279
}
1280
+ if (statisticsPb .getTransactionInfo () != null ) {
1281
+ this .transactionInfo = TransactionInfo .fromPb (statisticsPb .getTransactionInfo ());
1282
+ }
1206
1283
}
1207
1284
1208
1285
@ SuppressWarnings ("unchecked" )
@@ -1236,6 +1313,7 @@ protected JobStatistics(Builder builder) {
1236
1313
this .parentJobId = builder .parentJobId ;
1237
1314
this .scriptStatistics = builder .scriptStatistics ;
1238
1315
this .reservationUsage = builder .reservationUsage ;
1316
+ this .transactionInfo = builder .transactionInfo ;
1239
1317
}
1240
1318
1241
1319
/** Returns the creation time of the job in milliseconds since epoch. */
@@ -1279,6 +1357,11 @@ public List<ReservationUsage> getReservationUsage() {
1279
1357
return reservationUsage ;
1280
1358
}
1281
1359
1360
+ /** Info indicates the transaction ID associated with the job, if any. */
1361
+ public TransactionInfo getTransactionInfo () {
1362
+ return transactionInfo ;
1363
+ }
1364
+
1282
1365
ToStringHelper toStringHelper () {
1283
1366
return MoreObjects .toStringHelper (this )
1284
1367
.add ("creationTime" , creationTime )
@@ -1287,7 +1370,8 @@ ToStringHelper toStringHelper() {
1287
1370
.add ("numChildJobs" , numChildJobs )
1288
1371
.add ("parentJobId" , parentJobId )
1289
1372
.add ("scriptStatistics" , scriptStatistics )
1290
- .add ("reservationUsage" , reservationUsage );
1373
+ .add ("reservationUsage" , reservationUsage )
1374
+ .add ("transactionInfo" , transactionInfo );
1291
1375
}
1292
1376
1293
1377
@ Override
@@ -1303,7 +1387,8 @@ final int baseHashCode() {
1303
1387
numChildJobs ,
1304
1388
parentJobId ,
1305
1389
scriptStatistics ,
1306
- reservationUsage );
1390
+ reservationUsage ,
1391
+ transactionInfo );
1307
1392
}
1308
1393
1309
1394
final boolean baseEquals (JobStatistics jobStatistics ) {
@@ -1325,6 +1410,9 @@ com.google.api.services.bigquery.model.JobStatistics toPb() {
1325
1410
statistics .setReservationUsage (
1326
1411
Lists .transform (reservationUsage , ReservationUsage .TO_PB_FUNCTION ));
1327
1412
}
1413
+ if (transactionInfo != null ) {
1414
+ statistics .setTransactionInfo (transactionInfo .toPb ());
1415
+ }
1328
1416
return statistics ;
1329
1417
}
1330
1418
0 commit comments