@@ -56,6 +56,7 @@ public class QueryResponse implements Serializable {
5656 private final QueryResult result ;
5757 private final String etag ;
5858 private final JobId jobId ;
59+ private final Long numDmlAffectedRows ;
5960 private final boolean jobCompleted ;
6061 private final List <BigQueryError > executionErrors ;
6162
@@ -64,6 +65,7 @@ static final class Builder {
6465 private QueryResult result ;
6566 private String etag ;
6667 private JobId jobId ;
68+ private Long numDmlAffectedRows ;
6769 private boolean jobCompleted ;
6870 private List <BigQueryError > executionErrors ;
6971
@@ -84,6 +86,11 @@ Builder setJobId(JobId jobId) {
8486 return this ;
8587 }
8688
89+ Builder setNumDmlAffectedRows (Long numDmlAffectedRows ) {
90+ this .numDmlAffectedRows = numDmlAffectedRows ;
91+ return this ;
92+ }
93+
8794 Builder setJobCompleted (boolean jobCompleted ) {
8895 this .jobCompleted = jobCompleted ;
8996 return this ;
@@ -103,6 +110,7 @@ private QueryResponse(Builder builder) {
103110 this .result = builder .result ;
104111 this .etag = builder .etag ;
105112 this .jobId = builder .jobId ;
113+ this .numDmlAffectedRows = builder .numDmlAffectedRows ;
106114 this .jobCompleted = builder .jobCompleted ;
107115 this .executionErrors = builder .executionErrors != null ? builder .executionErrors
108116 : ImmutableList .<BigQueryError >of ();
@@ -134,6 +142,12 @@ public JobId getJobId() {
134142 return jobId ;
135143 }
136144
145+ /**
146+ * Returns the number of rows affected by a DML statement. Present only for DML statements INSERT,
147+ * UPDATE or DELETE.
148+ */
149+ public Long getNumDmlAffectedRows () { return numDmlAffectedRows ; }
150+
137151 /**
138152 * Returns whether the job running the query has completed or not. If {@link #getResult()} is not
139153 * {@code null}, this method will always return {@code true}. If this method returns {@code false}
@@ -168,14 +182,15 @@ public String toString() {
168182 .add ("result" , result )
169183 .add ("etag" , etag )
170184 .add ("jobId" , jobId )
185+ .add ("numDmlAffectedRows" , numDmlAffectedRows )
171186 .add ("jobCompleted" , jobCompleted )
172187 .add ("executionErrors" , executionErrors )
173188 .toString ();
174189 }
175190
176191 @ Override
177192 public final int hashCode () {
178- return Objects .hash (jobId );
193+ return Objects .hash (result , etag , jobId , numDmlAffectedRows , jobCompleted , executionErrors );
179194 }
180195
181196 @ Override
@@ -191,6 +206,7 @@ public final boolean equals(Object obj) {
191206 && Objects .equals (etag , response .etag )
192207 && Objects .equals (result , response .result )
193208 && Objects .equals (jobId , response .jobId )
209+ && Objects .equals (numDmlAffectedRows , response .numDmlAffectedRows )
194210 && Objects .equals (executionErrors , response .executionErrors );
195211 }
196212
0 commit comments