@Override public TableId apply(TableId tableId) { if (Strings.isNullOrEmpty(tableId.getProject())) { return tableId.setProjectId(projectId); } return tableId; } }));
@Override public com.google.api.services.bigquery.model.Table call() { return bigQueryRpc.getTable( completeTableId.getProject(), completeTableId.getDataset(), completeTableId.getTable(), optionsMap); } },
@Override public Boolean call() { return bigQueryRpc.deleteTable( completeTableId.getProject(), completeTableId.getDataset(), completeTableId.getTable()); } },
@Override public TableDataInsertAllResponse call() throws Exception { return bigQueryRpc.insertAll( tableId.getProject(), tableId.getDataset(), tableId.getTable(), requestPb); } },
@Override public TableDataList call() { return serviceOptions .getBigQueryRpcV2() .listTableData( completeTableId.getProject(), completeTableId.getDataset(), completeTableId.getTable(), optionsMap); } },
@Override ExtractJobConfiguration setProjectId(String projectId) { if (Strings.isNullOrEmpty(getSourceTable().getProject())) { return toBuilder().setSourceTable(getSourceTable().setProjectId(projectId)).build(); } return this; }
@Override LoadJobConfiguration setProjectId(String projectId) { if (Strings.isNullOrEmpty(getDestinationTable().getProject())) { return toBuilder().setDestinationTable(getDestinationTable().setProjectId(projectId)).build(); } return this; }
WriteChannelConfiguration setProjectId(String projectId) { if (Strings.isNullOrEmpty(getDestinationTable().getProject())) { return toBuilder().setDestinationTable(getDestinationTable().setProjectId(projectId)).build(); } return this; }
TableInfo setProjectId(String projectId) { if (Strings.isNullOrEmpty(getTableId().getProject())) { return toBuilder().setTableId(getTableId().setProjectId(projectId)).build(); } return this; }
@Test public void testSetProjectId() { CopyJobConfiguration configuration = COPY_JOB_CONFIGURATION_MULTIPLE_TABLES.setProjectId(TEST_PROJECT_ID); assertEquals(TEST_PROJECT_ID, configuration.getDestinationTable().getProject()); for (TableId sourceTable : configuration.getSourceTables()) { assertEquals(TEST_PROJECT_ID, sourceTable.getProject()); } }
@Override QueryJobConfiguration setProjectId(String projectId) { Builder builder = toBuilder(); if (getDestinationTable() != null && Strings.isNullOrEmpty(getDestinationTable().getProject())) { builder.setDestinationTable(getDestinationTable().setProjectId(projectId)); } if (getDefaultDataset() != null) { builder.setDefaultDataset(getDefaultDataset().setProjectId(projectId)); } return builder.build(); }
@Test public void testSetProjectId() { ExtractJobConfiguration configuration = EXTRACT_CONFIGURATION.setProjectId(TEST_PROJECT_ID); assertEquals(TEST_PROJECT_ID, configuration.getSourceTable().getProject()); }
private void compareTableIds(TableId expected, TableId value) { assertEquals(expected, value); assertEquals(expected.getProject(), value.getProject()); assertEquals(expected.getDataset(), value.getDataset()); assertEquals(expected.hashCode(), value.hashCode()); } }
@Test public void testSetProjectId() { LoadConfiguration configuration = LOAD_CONFIGURATION_CSV.setProjectId(TEST_PROJECT_ID); assertEquals(TEST_PROJECT_ID, configuration.getDestinationTable().getProject()); }
@Test public void testOf() { assertEquals(null, TABLE.getProject()); assertEquals("dataset", TABLE.getDataset()); assertEquals("table", TABLE.getTable()); assertEquals("project", TABLE_COMPLETE.getProject()); assertEquals("dataset", TABLE_COMPLETE.getDataset()); assertEquals("table", TABLE_COMPLETE.getTable()); }
@Test public void testSetProjectIdDoNotOverride() { TableInfo tableInfo = TableInfo.of(TABLE_ID, TABLE_DEFINITION).setProjectId("project"); tableInfo.setProjectId("not-override-project").toBuilder(); assertEquals("project", tableInfo.getTableId().getProject()); }
@Test public void testSetProjectIdDoNotOverride() { WriteChannelConfiguration configuration = WriteChannelConfiguration.of(TABLE_ID).setProjectId("project"); configuration.setProjectId("different-project").toBuilder(); assertEquals("project", configuration.getDestinationTable().getProject()); }
@Test public void testSetProjectId() { QueryJobConfiguration configuration = QUERY_JOB_CONFIGURATION.setProjectId(TEST_PROJECT_ID); assertEquals(TEST_PROJECT_ID, configuration.getDefaultDataset().getProject()); assertEquals(TEST_PROJECT_ID, configuration.getDestinationTable().getProject()); }
@Test public void testSetProjectIdDoNotOverride() { LoadConfiguration configuration = LOAD_CONFIGURATION_CSV .toBuilder() .setDestinationTable(TABLE_ID.setProjectId(TEST_PROJECT_ID)) .build() .setProjectId("do-not-update"); assertEquals(TEST_PROJECT_ID, configuration.getDestinationTable().getProject()); }
@Test public void testSetProjectIdDoNotOverride() { ExtractJobConfiguration configuration = EXTRACT_CONFIGURATION .toBuilder() .setSourceTable(TABLE_ID.setProjectId(TEST_PROJECT_ID)) .build() .setProjectId("do-not-update"); assertEquals(TEST_PROJECT_ID, configuration.getSourceTable().getProject()); }