Skip to content

Commit 32ccf56

Browse files
Praful MakaniJesseLovelace
authored andcommitted
---
yaml --- r: 14643 b: refs/heads/autosynth-asset c: cbe19f2 h: refs/heads/master i: 14641: 25c5234 14639: b2e15d9
1 parent 5698ae7 commit 32ccf56

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
@@ -122,7 +122,7 @@ refs/heads/autosynth-vision: b8e47d76578b5f150ef530072ea7e485e2b02ca0
122122
refs/heads/spanner: b01127f885b4611bf1852abb0ce481eeb7fcc131
123123
refs/tags/v0.68.0: 9cc799fcf68c82ab431d425fefa58ef615ce8e5b
124124
refs/tags/v0.69.0: 78f67a29e8b9c46ba01de566a2eae0fd1c03edea
125-
refs/heads/autosynth-asset: cb5f9c17a7d77ecaee724f135e51c7931bde7f05
125+
refs/heads/autosynth-asset: cbe19f24366e256d5669f07ac23c1274138ac2ec
126126
refs/heads/autosynth-automl: d4315b3596bac160e3439432c54435f44b09953e
127127
refs/heads/autosynth-bigquerydatatransfer: 2a9f3938237f85a8919602d74011326580ff387f
128128
refs/heads/autosynth-bigquerystorage: 99aee05df348f39d98b6fb23c292006f1d2a6c28

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