Skip to content

Commit 43c994a

Browse files
charlesliqlogicJesseLovelace
authored andcommitted
---
yaml --- r: 14323 b: refs/heads/autosynth-video-intelligence c: 4dc2a5e h: refs/heads/master i: 14321: bb00d72 14319: f57618a
1 parent 5044d76 commit 43c994a

5 files changed

Lines changed: 31 additions & 9 deletions

File tree

  • branches/autosynth-video-intelligence
    • google-cloud-clients/google-cloud-bigquery/src
    • google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/snippets

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ refs/heads/autosynth-container: f6384095f50b31bfc8208542a49181e158d3681c
117117
refs/heads/autosynth-dataproc: bc74a8841bc1693d7945d991d15979df550b1fd1
118118
refs/heads/autosynth-monitoring: e67db7395a868e5f6ecc3476eb4a91c47abd4234
119119
refs/heads/autosynth-pubsub: fd363d13793a853214eb8193c922b28c54e7a6b3
120-
refs/heads/autosynth-video-intelligence: 3d1165982108a5ff74b5a64e961652bec2444a7b
120+
refs/heads/autosynth-video-intelligence: 4dc2a5e8e27fb07a24538b395e55822880f7cd4e
121121
refs/heads/autosynth-vision: d758c43ba2ef4f4f7ad07b722617cb39fe3f29db
122122
refs/heads/spanner: 54a5e197bfe0a004e13c190427f46c3413ab572d
123123
refs/tags/v0.68.0: 9cc799fcf68c82ab431d425fefa58ef615ce8e5b

branches/autosynth-video-intelligence/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Field.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ public Builder setType(LegacySQLTypeName type, Field... subFields) {
125125
* Types</a>
126126
*/
127127
public Builder setType(LegacySQLTypeName type, FieldList subFields) {
128-
if (type == LegacySQLTypeName.RECORD) {
128+
// LegacySQLTypeName is not an enum, cannot use reference equal.
129+
if (LegacySQLTypeName.RECORD.equals(type)) {
129130
if (subFields == null || subFields.isEmpty()) {
130131
throw new IllegalArgumentException(
131132
"The " + type + " field must have at least one sub-field");

branches/autosynth-video-intelligence/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Job.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public boolean exists() {
189189
public boolean isDone() {
190190
checkNotDryRun("isDone");
191191
Job job = bigquery.getJob(getJobId(), JobOption.fields(BigQuery.JobField.STATUS));
192-
return job == null || job.getStatus().getState() == JobStatus.State.DONE;
192+
return job == null || JobStatus.State.DONE.equals(job.getStatus().getState());
193193
}
194194
/**
195195
* Blocks until this job completes its execution, either failing or succeeding. This method
@@ -293,7 +293,7 @@ public TableResult getQueryResults(QueryResultsOption... options)
293293

294294
// Get the job resource to determine if it has errored.
295295
Job job = this;
296-
if (job.getStatus() == null || job.getStatus().getState() != JobStatus.State.DONE) {
296+
if (job.getStatus() == null || !JobStatus.State.DONE.equals(job.getStatus().getState())) {
297297
job = reload();
298298
}
299299
if (job.getStatus() != null && job.getStatus().getError() != null) {
@@ -362,7 +362,7 @@ public TimedAttemptSettings createNextAttempt(
362362
@Override
363363
public boolean shouldRetry(Throwable prevThrowable, Job prevResponse) {
364364
return prevResponse != null
365-
&& prevResponse.getStatus().getState() != JobStatus.State.DONE;
365+
&& !JobStatus.State.DONE.equals(prevResponse.getStatus().getState());
366366
}
367367
},
368368
options.getClock());
@@ -377,7 +377,7 @@ public boolean shouldRetry(Throwable prevThrowable, Job prevResponse) {
377377
* <p>Example of reloading all fields until job status is DONE.
378378
*
379379
* <pre>{@code
380-
* while (job.getStatus().getState() != JobStatus.State.DONE) {
380+
* while (!JobStatus.State.DONE.equals(job.getStatus().getState())) {
381381
* Thread.sleep(1000L);
382382
* job = job.reload();
383383
* }
@@ -386,7 +386,7 @@ public boolean shouldRetry(Throwable prevThrowable, Job prevResponse) {
386386
* <p>Example of reloading status field until job status is DONE.
387387
*
388388
* <pre>{@code
389-
* while (job.getStatus().getState() != JobStatus.State.DONE) {
389+
* while (!JobStatus.State.DONE.equals(job.getStatus().getState())) {
390390
* Thread.sleep(1000L);
391391
* job = job.reload(BigQuery.JobOption.fields(BigQuery.JobField.STATUS));
392392
* }

branches/autosynth-video-intelligence/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
import static org.junit.Assert.assertEquals;
2020

21+
import java.io.ByteArrayInputStream;
22+
import java.io.ByteArrayOutputStream;
23+
import java.io.InputStream;
24+
import java.io.ObjectInputStream;
25+
import java.io.ObjectOutputStream;
2126
import org.junit.Test;
2227

2328
public class FieldTest {
@@ -92,6 +97,22 @@ public void testToAndFromPb() {
9297
compareFieldSchemas(field, Field.fromPb(field.toPb()));
9398
}
9499

100+
@Test
101+
public void testSubFieldWithClonedType() throws Exception {
102+
LegacySQLTypeName record = LegacySQLTypeName.RECORD;
103+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
104+
ObjectOutputStream oos = new ObjectOutputStream(baos);
105+
oos.writeObject(record);
106+
oos.flush();
107+
oos.close();
108+
InputStream is = new ByteArrayInputStream(baos.toByteArray());
109+
ObjectInputStream ois = new ObjectInputStream(is);
110+
LegacySQLTypeName clonedRecord = (LegacySQLTypeName) ois.readObject();
111+
ois.close();
112+
113+
Field.of("field", clonedRecord, Field.of("subfield", LegacySQLTypeName.BOOLEAN));
114+
}
115+
95116
private void compareFieldSchemas(Field expected, Field value) {
96117
assertEquals(expected, value);
97118
assertEquals(expected.getName(), value.getName());

branches/autosynth-video-intelligence/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/snippets/JobSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public boolean waitForWithOptions() throws InterruptedException {
113113
// [TARGET reload(JobOption...)]
114114
public JobStatus.State reload() throws InterruptedException {
115115
// [START ]
116-
while (job.getStatus().getState() != JobStatus.State.DONE) {
116+
while (!JobStatus.State.DONE.equals(job.getStatus().getState())) {
117117
Thread.sleep(1000L);
118118
job = job.reload();
119119
}
@@ -125,7 +125,7 @@ public JobStatus.State reload() throws InterruptedException {
125125
// [TARGET reload(JobOption...)]
126126
public JobStatus.State reloadStatus() throws InterruptedException {
127127
// [START ]
128-
while (job.getStatus().getState() != JobStatus.State.DONE) {
128+
while (!JobStatus.State.DONE.equals(job.getStatus().getState())) {
129129
Thread.sleep(1000L);
130130
job = job.reload(BigQuery.JobOption.fields(BigQuery.JobField.STATUS));
131131
}

0 commit comments

Comments
 (0)