@@ -44,6 +44,7 @@ public abstract class JobStatistics implements Serializable {
4444 private final String parentJobId ;
4545 private final ScriptStatistics scriptStatistics ;
4646 private final List <ReservationUsage > reservationUsage ;
47+ private final TransactionInfo transactionInfo ;
4748
4849 /** A Google BigQuery Copy Job statistics. */
4950 public static class CopyStatistics extends JobStatistics {
@@ -1178,6 +1179,78 @@ static ReservationUsage fromPb(
11781179 }
11791180 }
11801181
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+
11811254 abstract static class Builder <T extends JobStatistics , B extends Builder <T , B >> {
11821255
11831256 private Long creationTime ;
@@ -1187,6 +1260,7 @@ abstract static class Builder<T extends JobStatistics, B extends Builder<T, B>>
11871260 private String parentJobId ;
11881261 private ScriptStatistics scriptStatistics ;
11891262 private List <ReservationUsage > reservationUsage ;
1263+ private TransactionInfo transactionInfo ;
11901264
11911265 protected Builder () {}
11921266
@@ -1203,6 +1277,9 @@ protected Builder(com.google.api.services.bigquery.model.JobStatistics statistic
12031277 this .reservationUsage =
12041278 Lists .transform (statisticsPb .getReservationUsage (), ReservationUsage .FROM_PB_FUNCTION );
12051279 }
1280+ if (statisticsPb .getTransactionInfo () != null ) {
1281+ this .transactionInfo = TransactionInfo .fromPb (statisticsPb .getTransactionInfo ());
1282+ }
12061283 }
12071284
12081285 @ SuppressWarnings ("unchecked" )
@@ -1236,6 +1313,7 @@ protected JobStatistics(Builder builder) {
12361313 this .parentJobId = builder .parentJobId ;
12371314 this .scriptStatistics = builder .scriptStatistics ;
12381315 this .reservationUsage = builder .reservationUsage ;
1316+ this .transactionInfo = builder .transactionInfo ;
12391317 }
12401318
12411319 /** Returns the creation time of the job in milliseconds since epoch. */
@@ -1279,6 +1357,11 @@ public List<ReservationUsage> getReservationUsage() {
12791357 return reservationUsage ;
12801358 }
12811359
1360+ /** Info indicates the transaction ID associated with the job, if any. */
1361+ public TransactionInfo getTransactionInfo () {
1362+ return transactionInfo ;
1363+ }
1364+
12821365 ToStringHelper toStringHelper () {
12831366 return MoreObjects .toStringHelper (this )
12841367 .add ("creationTime" , creationTime )
@@ -1287,7 +1370,8 @@ ToStringHelper toStringHelper() {
12871370 .add ("numChildJobs" , numChildJobs )
12881371 .add ("parentJobId" , parentJobId )
12891372 .add ("scriptStatistics" , scriptStatistics )
1290- .add ("reservationUsage" , reservationUsage );
1373+ .add ("reservationUsage" , reservationUsage )
1374+ .add ("transactionInfo" , transactionInfo );
12911375 }
12921376
12931377 @ Override
@@ -1303,7 +1387,8 @@ final int baseHashCode() {
13031387 numChildJobs ,
13041388 parentJobId ,
13051389 scriptStatistics ,
1306- reservationUsage );
1390+ reservationUsage ,
1391+ transactionInfo );
13071392 }
13081393
13091394 final boolean baseEquals (JobStatistics jobStatistics ) {
@@ -1325,6 +1410,9 @@ com.google.api.services.bigquery.model.JobStatistics toPb() {
13251410 statistics .setReservationUsage (
13261411 Lists .transform (reservationUsage , ReservationUsage .TO_PB_FUNCTION ));
13271412 }
1413+ if (transactionInfo != null ) {
1414+ statistics .setTransactionInfo (transactionInfo .toPb ());
1415+ }
13281416 return statistics ;
13291417 }
13301418
0 commit comments