diff --git a/java/google/registry/export/UpdateSnapshotViewAction.java b/java/google/registry/export/UpdateSnapshotViewAction.java index f3562e91f..5284756d9 100644 --- a/java/google/registry/export/UpdateSnapshotViewAction.java +++ b/java/google/registry/export/UpdateSnapshotViewAction.java @@ -89,17 +89,16 @@ public class UpdateSnapshotViewAction implements Runnable { .setDatasetId(LATEST_SNAPSHOT_DATASET) .setTableId(kindName)) .setView(new ViewDefinition().setQuery( - SqlTemplate.create("SELECT * FROM [%DATASET%.%TABLE%]") + SqlTemplate.create("SELECT * FROM [%PROJECT%:%DATASET%.%TABLE%]") + .put("PROJECT", projectId) .put("DATASET", datasetId) .put("TABLE", tableId) .build()))); logger.infofmt( - "Updated view %s:%s to point at snapshot table %s:%s.", - LATEST_SNAPSHOT_DATASET, - kindName, - datasetId, - tableId); + "Updated view %s to point at snapshot table %s.", + String.format("[%s:%s.%s]", projectId, LATEST_SNAPSHOT_DATASET, kindName), + String.format("[%s:%s.%s]", projectId, datasetId, tableId)); } private static void updateTable(Bigquery bigquery, Table table) throws IOException { diff --git a/javatests/google/registry/export/UpdateSnapshotViewActionTest.java b/javatests/google/registry/export/UpdateSnapshotViewActionTest.java index 023b96374..a98c0aed7 100644 --- a/javatests/google/registry/export/UpdateSnapshotViewActionTest.java +++ b/javatests/google/registry/export/UpdateSnapshotViewActionTest.java @@ -82,18 +82,17 @@ public class UpdateSnapshotViewActionTest { public void before() throws Exception { when(bigqueryFactory.create(anyString(), anyString())).thenReturn(bigquery); when(bigquery.datasets()).thenReturn(bigqueryDatasets); - when(bigqueryDatasets.insert(eq("Project-Id"), any(Dataset.class))) + when(bigqueryDatasets.insert(anyString(), any(Dataset.class))) .thenReturn(bigqueryDatasetsInsert); when(bigquery.tables()).thenReturn(bigqueryTables); - when(bigqueryTables.update( - eq("Project-Id"), anyString(), anyString(), any(Table.class))) + when(bigqueryTables.update(anyString(), anyString(), anyString(), any(Table.class))) .thenReturn(bigqueryTablesUpdate); action = new UpdateSnapshotViewAction(); action.bigqueryFactory = bigqueryFactory; action.datasetId = "some_dataset"; action.kindName = "fookind"; - action.projectId = "Project-Id"; + action.projectId = "myproject"; action.tableId = "12345_fookind"; } @@ -116,14 +115,14 @@ public class UpdateSnapshotViewActionTest { // Check that the BigQuery factory was called in such a way that the dataset would be created // if it didn't already exist. - verify(bigqueryFactory).create("Project-Id", "latest_snapshot"); + verify(bigqueryFactory).create("myproject", "latest_snapshot"); // Check that we updated the view. ArgumentCaptor tableArg = ArgumentCaptor.forClass(Table.class); verify(bigqueryTables).update( - eq("Project-Id"), eq("latest_snapshot"), eq("fookind"), tableArg.capture()); + eq("myproject"), eq("latest_snapshot"), eq("fookind"), tableArg.capture()); assertThat(tableArg.getValue().getView().getQuery()) - .isEqualTo("SELECT * FROM [some_dataset.12345_fookind]"); + .isEqualTo("SELECT * FROM [myproject:some_dataset.12345_fookind]"); } @Test