Skip to content

Commit 4d59f2d

Browse files
committed
---
yaml --- r: 1621 b: refs/heads/master c: 84402ac h: refs/heads/master i: 1619: 155977f
1 parent 1c6ec09 commit 4d59f2d

62 files changed

Lines changed: 2002 additions & 2225 deletions

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 44a1533df7f7a4c3a4ed86503d03d98e6794c094
2+
refs/heads/master: 84402ac4ffc4e817b67ebeae9382683e7ce12b89
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: d1b373c30c176edc08692348167bec3a244bb823
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3

trunk/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ If you are using Maven, add this to your pom.xml file
2727
<dependency>
2828
<groupId>com.google.gcloud</groupId>
2929
<artifactId>gcloud-java</artifactId>
30-
<version>0.1.3</version>
30+
<version>0.1.2</version>
3131
</dependency>
3232
```
3333
If you are using Gradle, add this to your dependencies
3434
```Groovy
35-
compile 'com.google.gcloud:gcloud-java:0.1.3'
35+
compile 'com.google.gcloud:gcloud-java:0.1.2'
3636
```
3737
If you are using SBT, add this to your dependencies
3838
```Scala
39-
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.3"
39+
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.2"
4040
```
4141

4242
Example Applications

trunk/gcloud-java-bigquery/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ If you are using Maven, add this to your pom.xml file
2020
<dependency>
2121
<groupId>com.google.gcloud</groupId>
2222
<artifactId>gcloud-java-bigquery</artifactId>
23-
<version>0.1.3</version>
23+
<version>0.1.2</version>
2424
</dependency>
2525
```
2626
If you are using Gradle, add this to your dependencies
2727
```Groovy
28-
compile 'com.google.gcloud:gcloud-java-bigquery:0.1.3'
28+
compile 'com.google.gcloud:gcloud-java-bigquery:0.1.2'
2929
```
3030
If you are using SBT, add this to your dependencies
3131
```Scala
32-
libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.3"
32+
libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.2"
3333
```
3434

3535
Example Application

trunk/gcloud-java-bigquery/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.google.gcloud</groupId>
1313
<artifactId>gcloud-java-pom</artifactId>
14-
<version>0.1.4-SNAPSHOT</version>
14+
<version>0.1.3-SNAPSHOT</version>
1515
</parent>
1616
<properties>
1717
<site.installationModule>gcloud-java-bigquery</site.installationModule>

trunk/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,9 @@ public static JobListOption startPageToken(String pageToken) {
371371
* is not provided all job's fields are returned. {@code JobOption.fields()} can be used to
372372
* specify only the fields of interest. {@link JobInfo#jobId()}, {@link JobStatus#state()},
373373
* {@link JobStatus#error()} as well as type-specific configuration (e.g.
374-
* {@link QueryJobInfo#query()} for Query Jobs) are always returned, even if not specified.
375-
* {@link JobField#SELF_LINK} and {@link JobField#ETAG} can not be selected when listing jobs.
374+
* {@link QueryJobConfiguration#query()} for Query Jobs) are always returned, even if not
375+
* specified. {@link JobField#SELF_LINK} and {@link JobField#ETAG} can not be selected when
376+
* listing jobs.
376377
*/
377378
public static JobListOption fields(JobField... fields) {
378379
String selector = JobField.selector(fields);
@@ -397,8 +398,8 @@ private JobOption(BigQueryRpc.Option option, Object value) {
397398
* Returns an option to specify the job's fields to be returned by the RPC call. If this option
398399
* is not provided all job's fields are returned. {@code JobOption.fields()} can be used to
399400
* specify only the fields of interest. {@link JobInfo#jobId()} as well as type-specific
400-
* configuration (e.g. {@link QueryJobInfo#query()} for Query Jobs) are always returned, even if
401-
* not specified.
401+
* configuration (e.g. {@link QueryJobConfiguration#query()} for Query Jobs) are always
402+
* returned, even if not specified.
402403
*/
403404
public static JobOption fields(JobField... fields) {
404405
return new JobOption(BigQueryRpc.Option.FIELDS, JobField.selector(fields));
@@ -470,7 +471,7 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
470471
*
471472
* @throws BigQueryException upon failure
472473
*/
473-
<T extends JobInfo> T create(T job, JobOption... options) throws BigQueryException;
474+
JobInfo create(JobInfo job, JobOption... options) throws BigQueryException;
474475

475476
/**
476477
* Returns the requested dataset or {@code null} if not found.
@@ -611,14 +612,14 @@ Page<List<FieldValue>> listTableData(TableId tableId, TableDataListOption... opt
611612
*
612613
* @throws BigQueryException upon failure
613614
*/
614-
<T extends JobInfo> T getJob(String jobId, JobOption... options) throws BigQueryException;
615+
JobInfo getJob(String jobId, JobOption... options) throws BigQueryException;
615616

616617
/**
617618
* Returns the requested job or {@code null} if not found.
618619
*
619620
* @throws BigQueryException upon failure
620621
*/
621-
<T extends JobInfo> T getJob(JobId jobId, JobOption... options) throws BigQueryException;
622+
JobInfo getJob(JobId jobId, JobOption... options) throws BigQueryException;
622623

623624
/**
624625
* Lists the jobs.

trunk/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public Table call() {
191191
}
192192

193193
@Override
194-
public <T extends JobInfo> T create(T job, JobOption... options) throws BigQueryException {
194+
public JobInfo create(JobInfo job, JobOption... options) throws BigQueryException {
195195
final Job jobPb = setProjectId(job).toPb();
196196
final Map<BigQueryRpc.Option, ?> optionsMap = optionMap(options);
197197
try {
@@ -442,12 +442,12 @@ public List<FieldValue> apply(TableRow rowPb) {
442442
}
443443

444444
@Override
445-
public <T extends JobInfo> T getJob(String jobId, JobOption... options) throws BigQueryException {
445+
public JobInfo getJob(String jobId, JobOption... options) throws BigQueryException {
446446
return getJob(JobId.of(jobId), options);
447447
}
448448

449449
@Override
450-
public <T extends JobInfo> T getJob(final JobId jobId, JobOption... options)
450+
public JobInfo getJob(final JobId jobId, JobOption... options)
451451
throws BigQueryException {
452452
final Map<BigQueryRpc.Option, ?> optionsMap = optionMap(options);
453453
try {
@@ -457,7 +457,7 @@ public Job call() {
457457
return bigQueryRpc.getJob(jobId.job(), optionsMap);
458458
}
459459
}, options().retryParams(), EXCEPTION_HANDLER);
460-
return answer == null ? null : JobInfo.<T>fromPb(answer);
460+
return answer == null ? null : JobInfo.fromPb(answer);
461461
} catch (RetryHelper.RetryHelperException e) {
462462
throw BigQueryException.translateAndThrow(e);
463463
}
@@ -646,42 +646,48 @@ private TableId setProjectId(TableId table) {
646646
}
647647

648648
private JobInfo setProjectId(JobInfo job) {
649-
if (job instanceof CopyJobInfo) {
650-
CopyJobInfo copyJob = (CopyJobInfo) job;
651-
CopyJobInfo.Builder copyBuilder = copyJob.toBuilder();
652-
copyBuilder.destinationTable(setProjectId(copyJob.destinationTable()));
653-
copyBuilder.sourceTables(
654-
Lists.transform(copyJob.sourceTables(), new Function<TableId, TableId>() {
655-
@Override
656-
public TableId apply(TableId tableId) {
657-
return setProjectId(tableId);
658-
}
659-
}));
660-
return copyBuilder.build();
661-
}
662-
if (job instanceof QueryJobInfo) {
663-
QueryJobInfo queryJob = (QueryJobInfo) job;
664-
QueryJobInfo.Builder queryBuilder = queryJob.toBuilder();
665-
if (queryJob.destinationTable() != null) {
666-
queryBuilder.destinationTable(setProjectId(queryJob.destinationTable()));
667-
}
668-
if (queryJob.defaultDataset() != null) {
669-
queryBuilder.defaultDataset(setProjectId(queryJob.defaultDataset()));
670-
}
671-
return queryBuilder.build();
672-
}
673-
if (job instanceof ExtractJobInfo) {
674-
ExtractJobInfo extractJob = (ExtractJobInfo) job;
675-
ExtractJobInfo.Builder extractBuilder = extractJob.toBuilder();
676-
extractBuilder.sourceTable(setProjectId(extractJob.sourceTable()));
677-
return extractBuilder.build();
678-
}
679-
if (job instanceof LoadJobInfo) {
680-
LoadJobInfo loadJob = (LoadJobInfo) job;
681-
LoadJobInfo.Builder loadBuilder = loadJob.toBuilder();
682-
return loadBuilder.configuration(setProjectId(loadJob.configuration())).build();
683-
}
684-
return job;
649+
JobConfiguration configuration = job.configuration();
650+
JobInfo.Builder jobBuilder = job.toBuilder();
651+
switch (configuration.type()) {
652+
case COPY:
653+
CopyJobConfiguration copyConfiguration = (CopyJobConfiguration) configuration;
654+
CopyJobConfiguration.Builder copyBuilder = copyConfiguration.toBuilder();
655+
copyBuilder.sourceTables(
656+
Lists.transform(copyConfiguration.sourceTables(), new Function<TableId, TableId>() {
657+
@Override
658+
public TableId apply(TableId tableId) {
659+
return setProjectId(tableId);
660+
}
661+
}));
662+
copyBuilder.destinationTable(setProjectId(copyConfiguration.destinationTable()));
663+
jobBuilder.configuration(copyBuilder.build());
664+
break;
665+
case QUERY:
666+
QueryJobConfiguration queryConfiguration = (QueryJobConfiguration) configuration;
667+
QueryJobConfiguration.Builder queryBuilder = queryConfiguration.toBuilder();
668+
if (queryConfiguration.destinationTable() != null) {
669+
queryBuilder.destinationTable(setProjectId(queryConfiguration.destinationTable()));
670+
}
671+
if (queryConfiguration.defaultDataset() != null) {
672+
queryBuilder.defaultDataset(setProjectId(queryConfiguration.defaultDataset()));
673+
}
674+
jobBuilder.configuration(queryBuilder.build());
675+
break;
676+
case EXTRACT:
677+
ExtractJobConfiguration extractConfiguration = (ExtractJobConfiguration) configuration;
678+
ExtractJobConfiguration.Builder extractBuilder = extractConfiguration.toBuilder();
679+
extractBuilder.sourceTable(setProjectId(extractConfiguration.sourceTable()));
680+
jobBuilder.configuration(extractBuilder.build());
681+
break;
682+
case LOAD:
683+
LoadJobConfiguration loadConfiguration = (LoadJobConfiguration) configuration;
684+
jobBuilder.configuration((LoadJobConfiguration) setProjectId(loadConfiguration));
685+
break;
686+
default:
687+
// never reached
688+
throw new IllegalArgumentException("Job configuration is not supported");
689+
}
690+
return jobBuilder.build();
685691
}
686692

687693
private QueryRequest setProjectId(QueryRequest request) {

0 commit comments

Comments
 (0)