Skip to content

Commit 73d62a7

Browse files
committed
---
yaml --- r: 2139 b: refs/heads/pubsub-alpha c: 824c46c h: refs/heads/master i: 2137: d85bb9e 2135: a14cbcd
1 parent c1145e2 commit 73d62a7

44 files changed

Lines changed: 946 additions & 139 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

[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: ce9b5c1d3676bca7a4687b91c8d348d30c7eccda
6+
refs/heads/pubsub-alpha: 824c46c55e09c3d7cc4ea45144a159724e8ed609
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/BaseTableInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public enum Type {
9797
/**
9898
* Base builder for tables.
9999
*
100-
* @param <T> the table type.
101-
* @param <B> the table builder.
100+
* @param <T> the table type
101+
* @param <B> the table builder
102102
*/
103103
public abstract static class Builder<T extends BaseTableInfo, B extends Builder<T, B>> {
104104

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,31 +500,31 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
500500
/**
501501
* Deletes the requested dataset.
502502
*
503-
* @return {@code true} if dataset was deleted, {@code false} if it was not found.
503+
* @return {@code true} if dataset was deleted, {@code false} if it was not found
504504
* @throws BigQueryException upon failure
505505
*/
506506
boolean delete(String datasetId, DatasetDeleteOption... options) throws BigQueryException;
507507

508508
/**
509509
* Deletes the requested dataset.
510510
*
511-
* @return {@code true} if dataset was deleted, {@code false} if it was not found.
511+
* @return {@code true} if dataset was deleted, {@code false} if it was not found
512512
* @throws BigQueryException upon failure
513513
*/
514514
boolean delete(DatasetId datasetId, DatasetDeleteOption... options) throws BigQueryException;
515515

516516
/**
517517
* Deletes the requested table.
518518
*
519-
* @return {@code true} if table was deleted, {@code false} if it was not found.
519+
* @return {@code true} if table was deleted, {@code false} if it was not found
520520
* @throws BigQueryException upon failure
521521
*/
522522
boolean delete(String datasetId, String tableId) throws BigQueryException;
523523

524524
/**
525525
* Deletes the requested table.
526526
*
527-
* @return {@code true} if table was deleted, {@code false} if it was not found.
527+
* @return {@code true} if table was deleted, {@code false} if it was not found
528528
* @throws BigQueryException upon failure
529529
*/
530530
boolean delete(TableId tableId) throws BigQueryException;

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
import java.util.Objects;
99

1010
/**
11-
* Google Cloud BigQuery Job Error. Objects of this class represent errors occurred during the
12-
* execution of a BigQuery Job.
11+
* Google Cloud BigQuery Error. Objects of this class represent errors encountered by the BigQuery
12+
* service while executing a request. A BigQuery Job that terminated with an error has a non-null
13+
* {@link JobStatus#error()}. A job can also encounter errors during its execution that do not cause
14+
* the whole job to fail (see {@link JobStatus#executionErrors()}). Similarly, queries and insert
15+
* all requests can cause BigQuery errors that do not mean the whole operation failed (see
16+
* {@link QueryResponse#executionErrors()} and {@link InsertAllResponse#insertErrors()}). When a
17+
* {@link BigQueryException} is thrown the BigQuery Error that caused it, if any, can be accessed
18+
* with {@link BigQueryException#error()}.
1319
*/
1420
public class BigQueryError implements Serializable {
1521

@@ -34,14 +40,14 @@ public ErrorProto apply(BigQueryError error) {
3440
private final String debugInfo;
3541
private final String message;
3642

37-
BigQueryError(String reason, String location, String message, String debugInfo) {
43+
public BigQueryError(String reason, String location, String message, String debugInfo) {
3844
this.reason = reason;
3945
this.location = location;
4046
this.debugInfo = debugInfo;
4147
this.message = message;
4248
}
4349

44-
BigQueryError(String reason, String location, String message) {
50+
public BigQueryError(String reason, String location, String message) {
4551
this.reason = reason;
4652
this.location = location;
4753
this.message = message;

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,23 @@ public class BigQueryException extends BaseServiceException {
3131
private static final long serialVersionUID = -5504832700512784654L;
3232
public static final int UNKNOWN_CODE = -1;
3333

34+
private final BigQueryError error;
35+
3436
public BigQueryException(int code, String message, boolean retryable) {
37+
this(code, message, retryable, null);
38+
}
39+
40+
public BigQueryException(int code, String message, boolean retryable, BigQueryError error) {
3541
super(code, message, retryable);
42+
this.error = error;
43+
}
44+
45+
/**
46+
* Returns the {@link BigQueryError} that caused this exception. Returns {@code null} if none
47+
* exists.
48+
*/
49+
public BigQueryError error() {
50+
return error;
3651
}
3752

3853
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public Dataset update(DatasetInfo datasetInfo, BigQuery.DatasetOption... options
184184
/**
185185
* Deletes this dataset.
186186
*
187-
* @return {@code true} if dataset was deleted, {@code false} if it was not found.
187+
* @return {@code true} if dataset was deleted, {@code false} if it was not found
188188
* @throws BigQueryException upon failure
189189
*/
190190
public boolean delete() {

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/JobInfo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs">Jobs</a>
3535
*
36-
* @param <S> the statistics type.
36+
* @param <S> the statistics type
3737
*/
3838
public abstract class JobInfo<S extends JobStatistics> implements Serializable {
3939

@@ -92,9 +92,9 @@ public enum WriteDisposition {
9292
/**
9393
* Base builder for jobs.
9494
*
95-
* @param <T> the job type.
96-
* @param <S> the job statistics type.
97-
* @param <B> the job builder.
95+
* @param <T> the job type
96+
* @param <S> the job statistics type
97+
* @param <B> the job builder
9898
*/
9999
public abstract static class Builder<T extends JobInfo, S extends JobStatistics,
100100
B extends Builder<T, S, B>> {

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();

0 commit comments

Comments
 (0)