Skip to content

Commit 294aa9c

Browse files
Praful MakaniJesseLovelace
authored andcommitted
---
yaml --- r: 13185 b: refs/heads/autosynth-speech c: cbe19f2 h: refs/heads/master i: 13183: 2e9f31b
1 parent 887917e commit 294aa9c

6 files changed

Lines changed: 31 additions & 4 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ refs/heads/autosynth-redis: 4c68cb0fbc599124e717ab3f24bd8a8a5d085ca9
141141
refs/heads/autosynth-scheduler: 2f0fe714a8541dc72f88b45bddd8748e5f21cf29
142142
refs/heads/autosynth-securitycenter: 8e95447ccb176c3648880ee0cb926cd1f4065156
143143
refs/heads/autosynth-spanner: 563dc6c78c6a2579b681f441f0a9b59005212394
144-
refs/heads/autosynth-speech: cb5f9c17a7d77ecaee724f135e51c7931bde7f05
144+
refs/heads/autosynth-speech: cbe19f24366e256d5669f07ac23c1274138ac2ec
145145
refs/heads/autosynth-tasks: afc9f4da54964dea5e7f3a9b164db282fc35db5c
146146
refs/heads/autosynth-texttospeech: a447278ab2ec3975aab3b641549c6780eac0a07a
147147
refs/heads/autosynth-trace: 80c58aa2fb54b0a9c6876f2c21aa8d19cf55962e

branches/autosynth-speech/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,11 @@ private static Tuple<? extends Page<FieldValueList>, Long> listTableData(
625625
final BigQueryOptions serviceOptions,
626626
final Map<BigQueryRpc.Option, ?> optionsMap) {
627627
try {
628-
final TableId completeTableId = tableId.setProjectId(serviceOptions.getProjectId());
628+
final TableId completeTableId =
629+
tableId.setProjectId(
630+
Strings.isNullOrEmpty(serviceOptions.getProjectId())
631+
? tableId.getProject()
632+
: serviceOptions.getProjectId());
629633
TableDataList result =
630634
runWithRetries(
631635
new Callable<TableDataList>() {

branches/autosynth-speech/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableInfo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121

2222
import com.google.api.client.util.Data;
23+
import com.google.api.client.util.Strings;
2324
import com.google.api.core.BetaApi;
2425
import com.google.api.services.bigquery.model.Table;
2526
import com.google.common.base.Function;
@@ -396,7 +397,10 @@ public static TableInfo of(TableId tableId, TableDefinition definition) {
396397
}
397398

398399
TableInfo setProjectId(String projectId) {
399-
return toBuilder().setTableId(getTableId().setProjectId(projectId)).build();
400+
if (Strings.isNullOrEmpty(getTableId().getProject())) {
401+
return toBuilder().setTableId(getTableId().setProjectId(projectId)).build();
402+
}
403+
return this;
400404
}
401405

402406
Table toPb() {

branches/autosynth-speech/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/WriteChannelConfiguration.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

21+
import com.google.api.client.util.Strings;
2122
import com.google.api.services.bigquery.model.JobConfigurationLoad;
2223
import com.google.cloud.bigquery.JobInfo.CreateDisposition;
2324
import com.google.cloud.bigquery.JobInfo.SchemaUpdateOption;
@@ -390,7 +391,10 @@ public int hashCode() {
390391
}
391392

392393
WriteChannelConfiguration setProjectId(String projectId) {
393-
return toBuilder().setDestinationTable(getDestinationTable().setProjectId(projectId)).build();
394+
if (Strings.isNullOrEmpty(getDestinationTable().getProject())) {
395+
return toBuilder().setDestinationTable(getDestinationTable().setProjectId(projectId)).build();
396+
}
397+
return this;
394398
}
395399

396400
com.google.api.services.bigquery.model.JobConfiguration toPb() {

branches/autosynth-speech/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableInfoTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ public void testSetProjectId() {
226226
assertEquals("project", VIEW_INFO.setProjectId("project").getTableId().getProject());
227227
}
228228

229+
@Test
230+
public void testSetProjectIdDoNotOverride() {
231+
TableInfo tableInfo = TableInfo.of(TABLE_ID, TABLE_DEFINITION).setProjectId("project");
232+
tableInfo.setProjectId("not-override-project").toBuilder();
233+
assertEquals("project", tableInfo.getTableId().getProject());
234+
}
235+
229236
private void compareTableInfo(TableInfo expected, TableInfo value) {
230237
assertEquals(expected, value);
231238
assertEquals(expected.getTableId(), value.getTableId());

branches/autosynth-speech/google-cloud-clients/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/WriteChannelConfigurationTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ public void testToPbAndFromPb() {
164164
compareLoadConfiguration(configuration, WriteChannelConfiguration.fromPb(configuration.toPb()));
165165
}
166166

167+
@Test
168+
public void testSetProjectIdDoNotOverride() {
169+
WriteChannelConfiguration configuration =
170+
WriteChannelConfiguration.of(TABLE_ID).setProjectId("project");
171+
configuration.setProjectId("different-project").toBuilder();
172+
assertEquals("project", configuration.getDestinationTable().getProject());
173+
}
174+
167175
private void compareLoadConfiguration(
168176
WriteChannelConfiguration expected, WriteChannelConfiguration value) {
169177
assertEquals(expected, value);

0 commit comments

Comments
 (0)