Skip to content

Commit cf9878c

Browse files
charlesliqlogicJesseLovelace
authored andcommitted
---
yaml --- r: 13715 b: refs/heads/autosynth-logging c: 4dc2a5e h: refs/heads/master i: 13713: 9f2695e 13711: 1bbfccf
1 parent 5187aaa commit cf9878c

5 files changed

Lines changed: 31 additions & 9 deletions

File tree

  • branches/autosynth-logging
    • 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
@@ -105,7 +105,7 @@ refs/tags/v0.61.0: e4b526656bb1bf5eefd0ee578b7405147821225e
105105
refs/tags/v0.62.0: bbede7385d48ba08f487bdd29ec10668ace96396
106106
refs/heads/0.60.0-alpha: 10939381ffe0b8da32db4fe3087c86e3aa7f3e55
107107
refs/heads/autosynth-dlp: 90e4efe3be392e89dc36bce22afab981a905b1bc
108-
refs/heads/autosynth-logging: 3d1165982108a5ff74b5a64e961652bec2444a7b
108+
refs/heads/autosynth-logging: 4dc2a5e8e27fb07a24538b395e55822880f7cd4e
109109
refs/heads/dupes: 3478c5d81fd242d0e985656645a679420a2060c2
110110
refs/tags/v0.63.0: 94f19b71d40f46b36120e7b9d78a1a3d41bfcbd6
111111
refs/tags/v0.64.0: 456e8fbd129deced3ca025f239a2d8a82bde1d0a

branches/autosynth-logging/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-logging/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-logging/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-logging/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)