Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa38428

Browse files
feat: return JobID with TableResult (#2689)
* chore: improve job create retry* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md* chore: remove option 2* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md* chore: pass jobid from job.getQUeryResults()* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md* choreL set jobID as null when empty* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md* chore: add IT tests* chore: complete tests* chore: make setJobId package private* chore: remove redundant job ID setting* 🦉 Updates from OwlBot post-processorSeehttps://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md---------Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parente371e65 commitaa38428

File tree

5 files changed

+78
-11
lines changed

5 files changed

+78
-11
lines changed

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ If you are using Maven without the BOM, add this to your dependencies:
5353
If you are using Gradle 5.x or later, add this to your dependencies:
5454

5555
```Groovy
56-
implementation platform('com.google.cloud:libraries-bom:26.16.0')
56+
implementation platform('com.google.cloud:libraries-bom:26.17.0')
5757
5858
implementation 'com.google.cloud:google-cloud-bigquery'
5959
```
6060
If you are using Gradle without BOM, add this to your dependencies:
6161

6262
```Groovy
63-
implementation 'com.google.cloud:google-cloud-bigquery:2.27.0'
63+
implementation 'com.google.cloud:google-cloud-bigquery:2.27.1'
6464
```
6565

6666
If you are using SBT, add this to your dependencies:
6767

6868
```Scala
69-
libraryDependencies+="com.google.cloud"%"google-cloud-bigquery"%"2.27.0"
69+
libraryDependencies+="com.google.cloud"%"google-cloud-bigquery"%"2.27.1"
7070
```
7171
<!-- {x-version-update-end}-->
7272

@@ -350,7 +350,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
350350
[kokoro-badge-link-5]:http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java11.html
351351
[stability-image]:https://img.shields.io/badge/stability-stable-green
352352
[maven-version-image]:https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquery.svg
353-
[maven-version-link]:https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.27.0
353+
[maven-version-link]:https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.27.1
354354
[authentication]:https://github.com/googleapis/google-cloud-java#authentication
355355
[auth-scopes]:https://developers.google.com/identity/protocols/oauth2/scopes
356356
[predefined-iam-roles]:https://cloud.google.com/iam/docs/understanding-roles#predefined_roles

‎google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public com.google.api.services.bigquery.model.Job call() {
411411
}
412412
},
413413
getOptions().getRetrySettings(),
414-
EXCEPTION_HANDLER,
414+
BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
415415
getOptions().getClock(),
416416
DEFAULT_RETRY_CONFIG));
417417
}catch (BigQueryRetryHelper.BigQueryRetryHelperExceptione) {
@@ -1334,7 +1334,7 @@ public com.google.api.services.bigquery.model.QueryResponse call() {
13341334
List<BigQueryError>bigQueryErrors =
13351335
Lists.transform(results.getErrors(),BigQueryError.FROM_PB_FUNCTION);
13361336
// Throwing BigQueryException since there may be no JobId and we want to stay consistent
1337-
// with the case where therethereisa HTTP error
1337+
// with the case where there isan HTTP error
13381338
thrownewBigQueryException(bigQueryErrors);
13391339
}
13401340

@@ -1369,7 +1369,9 @@ public com.google.api.services.bigquery.model.QueryResponse call() {
13691369
newQueryPageFetcher(jobId,schema,getOptions(),cursor,optionMap(options)),
13701370
cursor,
13711371
// cache first page of result
1372-
transformTableData(results.getRows(),schema)));
1372+
transformTableData(results.getRows(),schema)),
1373+
// Return the JobID of the successful job
1374+
jobId);
13731375
}
13741376
// only 1 page of result
13751377
returnnewTableResult(
@@ -1378,7 +1380,9 @@ public com.google.api.services.bigquery.model.QueryResponse call() {
13781380
newPageImpl<>(
13791381
newTableDataPageFetcher(null,schema,getOptions(),null,optionMap(options)),
13801382
null,
1381-
transformTableData(results.getRows(),schema)));
1383+
transformTableData(results.getRows(),schema)),
1384+
// Return the JobID of the successful job
1385+
results.getJobReference() !=null ?JobId.fromPb(results.getJobReference()) :null);
13821386
}
13831387

13841388
@Override

‎google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Job.java‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,20 @@ public TableResult getQueryResults(QueryResultsOption... options)
311311
// Listing table data might fail, such as with CREATE VIEW queries.
312312
// Avoid a tabledata.list API request by returning an empty TableResult.
313313
if (response.getTotalRows() ==0) {
314-
returnnewEmptyTableResult(response.getSchema());
314+
TableResultemptyTableResult =newEmptyTableResult(response.getSchema());
315+
emptyTableResult.setJobId(job.getJobId());
316+
returnemptyTableResult;
315317
}
316318

317319
TableIdtable =
318320
((QueryJobConfiguration)getConfiguration()).getDestinationTable() ==null
319321
? ((QueryJobConfiguration)job.getConfiguration()).getDestinationTable()
320322
: ((QueryJobConfiguration)getConfiguration()).getDestinationTable();
321-
returnbigquery.listTableData(
322-
table,response.getSchema(),listOptions.toArray(newTableDataListOption[0]));
323+
TableResulttableResult =
324+
bigquery.listTableData(
325+
table,response.getSchema(),listOptions.toArray(newTableDataListOption[0]));
326+
tableResult.setJobId(job.getJobId());
327+
returntableResult;
323328
}
324329

325330
privateQueryResponsewaitForQueryResults(

‎google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableResult.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public class TableResult implements Page<FieldValueList>, Serializable {
3535
@NullableprivatefinalSchemaschema;
3636
privatefinallongtotalRows;
3737
privatefinalPage<FieldValueList>pageNoSchema;
38+
@NullableprivateJobIdjobId =null;
39+
40+
// package-private so job id is not set outside the package.
41+
voidsetJobId(@NullableJobIdjobId) {
42+
this.jobId =jobId;
43+
}
44+
45+
publicJobIdgetJobId() {
46+
returnjobId;
47+
}
3848

3949
/**
4050
* If {@code schema} is non-null, {@code TableResult} adds the schema to {@code FieldValueList}s
@@ -47,6 +57,15 @@ public TableResult(Schema schema, long totalRows, Page<FieldValueList> pageNoSch
4757
this.pageNoSchema =checkNotNull(pageNoSchema);
4858
}
4959

60+
@InternalApi("Exposed for testing")
61+
publicTableResult(
62+
Schemaschema,longtotalRows,Page<FieldValueList>pageNoSchema,JobIdjobId) {
63+
this.schema =schema;
64+
this.totalRows =totalRows;
65+
this.pageNoSchema =checkNotNull(pageNoSchema);
66+
this.jobId =jobId;
67+
}
68+
5069
/** Returns the schema of the results. Null if the schema is not supplied. */
5170
publicSchemagetSchema() {
5271
returnschema;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp