Skip to content

Commit a14cbcd

Browse files
committed
---
yaml --- r: 2135 b: refs/heads/pubsub-alpha c: d03e5a7 h: refs/heads/master i: 2133: 31909fd 2131: 932fdc8 2127: 57176b8
1 parent 260965d commit a14cbcd

12 files changed

Lines changed: 754 additions & 13 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ refs/heads/master: 689bbb466df4b2d5d2483d6edb8ac5c7c7f7c6fa
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
6-
refs/heads/pubsub-alpha: ea21d237dc8cc052802c0a5cf907abcdc2801e66
6+
refs/heads/pubsub-alpha: d03e5a7d80dc17d9012476557015e4f44be64687
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
88
refs/heads/update-datastore: 482954f2c5055231e5b3122ea91d2ba00ce8187c
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

branches/pubsub-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExtractJobInfo.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,23 @@ public static ExtractJobInfo of(TableId sourceTable, List<String> destinationUri
263263
return builder(sourceTable, destinationUris).build();
264264
}
265265

266+
/**
267+
* Returns a BigQuery Extract Job for the given source table, format and destination URI. Job's id
268+
* is chosen by the service.
269+
*/
270+
public static ExtractJobInfo of(TableId sourceTable, String format, String destinationUri) {
271+
return builder(sourceTable, destinationUri).format(format).build();
272+
}
273+
274+
/**
275+
* Returns a BigQuery Extract Job for the given source table, format and destination URIs. Job's
276+
* id is chosen by the service.
277+
*/
278+
public static ExtractJobInfo of(TableId sourceTable, String format,
279+
List<String> destinationUris) {
280+
return builder(sourceTable, destinationUris).format(format).build();
281+
}
282+
266283
/**
267284
* Returns a BigQuery Extract Job for the given source table and destination URI. Job's id is set
268285
* to the provided value.
@@ -279,6 +296,24 @@ public static ExtractJobInfo of(JobId jobId, TableId sourceTable, List<String> d
279296
return builder(sourceTable, destinationUris).jobId(jobId).build();
280297
}
281298

299+
/**
300+
* Returns a BigQuery Extract Job for the given source table, format and destination URI. Job's id
301+
* is set to the provided value.
302+
*/
303+
public static ExtractJobInfo of(JobId jobId, TableId sourceTable, String format,
304+
String destinationUri) {
305+
return builder(sourceTable, destinationUri).format(format).jobId(jobId).build();
306+
}
307+
308+
/**
309+
* Returns a BigQuery Extract Job for the given source table, format and destination URIs. Job's
310+
* id is set to the provided value.
311+
*/
312+
public static ExtractJobInfo of(JobId jobId, TableId sourceTable, String format,
313+
List<String> destinationUris) {
314+
return builder(sourceTable, destinationUris).format(format).jobId(jobId).build();
315+
}
316+
282317
@SuppressWarnings("unchecked")
283318
static ExtractJobInfo fromPb(Job jobPb) {
284319
return new Builder(jobPb).build();

branches/pubsub-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobStatistics.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.google.api.services.bigquery.model.JobStatistics4;
66
import com.google.common.base.MoreObjects;
77
import com.google.common.base.MoreObjects.ToStringHelper;
8+
import com.google.common.collect.Lists;
89

910
import java.io.Serializable;
1011
import java.util.List;
@@ -242,13 +243,15 @@ public static class QueryStatistics extends JobStatistics {
242243
private final Boolean cacheHit;
243244
private final Long totalBytesBilled;
244245
private final Long totalBytesProcessed;
246+
private final List<QueryStage> queryPlan;
245247

246248
static final class Builder extends JobStatistics.Builder<QueryStatistics, Builder> {
247249

248250
private Integer billingTier;
249251
private Boolean cacheHit;
250252
private Long totalBytesBilled;
251253
private Long totalBytesProcessed;
254+
private List<QueryStage> queryPlan;
252255

253256
private Builder() {}
254257

@@ -258,6 +261,10 @@ private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsP
258261
this.cacheHit = statisticsPb.getQuery().getCacheHit();
259262
this.totalBytesBilled = statisticsPb.getQuery().getTotalBytesBilled();
260263
this.totalBytesProcessed = statisticsPb.getQuery().getTotalBytesProcessed();
264+
if (statisticsPb.getQuery().getQueryPlan() != null) {
265+
this.queryPlan =
266+
Lists.transform(statisticsPb.getQuery().getQueryPlan(), QueryStage.FROM_PB_FUNCTION);
267+
}
261268
}
262269

263270
Builder billingTier(Integer billingTier) {
@@ -280,6 +287,11 @@ Builder totalBytesProcessed(Long totalBytesProcessed) {
280287
return self();
281288
}
282289

290+
Builder queryPlan(List<QueryStage> queryPlan) {
291+
this.queryPlan = queryPlan;
292+
return self();
293+
}
294+
283295
@Override
284296
QueryStatistics build() {
285297
return new QueryStatistics(this);
@@ -292,6 +304,7 @@ private QueryStatistics(Builder builder) {
292304
this.cacheHit = builder.cacheHit;
293305
this.totalBytesBilled = builder.totalBytesBilled;
294306
this.totalBytesProcessed = builder.totalBytesProcessed;
307+
this.queryPlan = builder.queryPlan;
295308
}
296309

297310
/**
@@ -325,13 +338,26 @@ public Long totalBytesProcessed() {
325338
return totalBytesProcessed;
326339
}
327340

341+
/**
342+
* Returns the query plan as a list of stages or {@code null} if a query plan is not available.
343+
* Each stage involves a number of steps that read from data sources, perform a series of
344+
* transformations on the input, and emit an output to a future stage (or the final result). The
345+
* query plan is available for a completed query job and is retained for 7 days.
346+
*
347+
* @see <a href="https://cloud.google.com/bigquery/query-plan-explanation">Query Plan</a>
348+
*/
349+
public List<QueryStage> queryPlan() {
350+
return queryPlan;
351+
}
352+
328353
@Override
329354
ToStringHelper toStringHelper() {
330355
return super.toStringHelper()
331356
.add("billingTier", billingTier)
332357
.add("cacheHit", cacheHit)
333358
.add("totalBytesBilled", totalBytesBilled)
334-
.add("totalBytesProcessed", totalBytesProcessed);
359+
.add("totalBytesProcessed", totalBytesProcessed)
360+
.add("queryPlan", queryPlan);
335361
}
336362

337363
@Override
@@ -343,7 +369,7 @@ public boolean equals(Object obj) {
343369
@Override
344370
public int hashCode() {
345371
return Objects.hash(super.hashCode(), billingTier, cacheHit, totalBytesBilled,
346-
totalBytesProcessed);
372+
totalBytesProcessed, queryPlan);
347373
}
348374

349375
@Override
@@ -353,6 +379,9 @@ com.google.api.services.bigquery.model.JobStatistics toPb() {
353379
queryStatisticsPb.setCacheHit(cacheHit);
354380
queryStatisticsPb.setTotalBytesBilled(totalBytesBilled);
355381
queryStatisticsPb.setTotalBytesProcessed(totalBytesProcessed);
382+
if (queryPlan != null) {
383+
queryStatisticsPb.setQueryPlan(Lists.transform(queryPlan, QueryStage.TO_PB_FUNCTION));
384+
}
356385
return super.toPb().setQuery(queryStatisticsPb);
357386
}
358387

branches/pubsub-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadJobInfo.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,23 @@ public static LoadJobInfo of(TableId destinationTable, List<String> sourceUris)
407407
return builder(destinationTable, sourceUris).build();
408408
}
409409

410+
/**
411+
* Returns a BigQuery Load Job for the given destination table, format and source URI. Job's id is
412+
* chosen by the service.
413+
*/
414+
public static LoadJobInfo of(TableId destinationTable, FormatOptions format, String sourceUri) {
415+
return builder(destinationTable, sourceUri).formatOptions(format).build();
416+
}
417+
418+
/**
419+
* Returns a BigQuery Load Job for the given destination table, format and source URIs. Job's id
420+
* is chosen by the service.
421+
*/
422+
public static LoadJobInfo of(TableId destinationTable, FormatOptions format,
423+
List<String> sourceUris) {
424+
return builder(destinationTable, sourceUris).formatOptions(format).build();
425+
}
426+
410427
/**
411428
* Returns a BigQuery Load Job for the given destination table and source URI. Job's id is set to
412429
* the provided value.
@@ -423,6 +440,24 @@ public static LoadJobInfo of(JobId jobId, TableId destinationTable, List<String>
423440
return builder(destinationTable, sourceUris).jobId(jobId).build();
424441
}
425442

443+
/**
444+
* Returns a BigQuery Load Job for the given destination table, format, and source URI. Job's id
445+
* is set to the provided value.
446+
*/
447+
public static LoadJobInfo of(JobId jobId, TableId destinationTable, FormatOptions format,
448+
String sourceUri) {
449+
return builder(destinationTable, sourceUri).formatOptions(format).jobId(jobId).build();
450+
}
451+
452+
/**
453+
* Returns a BigQuery Load Job for the given destination table, format and source URIs. Job's id
454+
* is set to the provided value.
455+
*/
456+
public static LoadJobInfo of(JobId jobId, TableId destinationTable, FormatOptions format,
457+
List<String> sourceUris) {
458+
return builder(destinationTable, sourceUris).formatOptions(format).jobId(jobId).build();
459+
}
460+
426461
@SuppressWarnings("unchecked")
427462
static LoadJobInfo fromPb(Job jobPb) {
428463
return new Builder(jobPb).build();

branches/pubsub-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryJobInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public enum Priority {
5353

5454
/**
5555
* Query is queued and started as soon as idle resources are available, usually within a few
56-
* minutes. If a {@link Priority#BATCH} query hasn't started within 3 hours, its priority is
57-
* changed to {@link Priority#INTERACTIVE}.
56+
* minutes. If the query hasn't started within 3 hours, its priority is changed to
57+
* {@link Priority#INTERACTIVE}.
5858
*/
5959
BATCH
6060
}

0 commit comments

Comments
 (0)