Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public Dataset apply(DatasetList.Datasets datasetPb) {
.setFriendlyName(datasetPb.getFriendlyName())
.setId(datasetPb.getId())
.setKind(datasetPb.getKind())
.setLocation(datasetPb.getLocation())
.setLabels(datasetPb.getLabels());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,22 @@ public class BigQueryImplTest {
Acl.of(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER),
Acl.of(new Acl.View(TableId.of(PROJECT, "dataset", "table"))));
private static final DatasetInfo DATASET_INFO =
DatasetInfo.newBuilder(DATASET).setAcl(ACCESS_RULES).setDescription("description").build();
DatasetInfo.newBuilder(DATASET)
.setAcl(ACCESS_RULES)
.setDescription("description")
.setLocation(LOCATION)
.build();
private static final DatasetInfo DATASET_INFO_WITH_PROJECT =
DatasetInfo.newBuilder(PROJECT, DATASET)
.setAcl(ACCESS_RULES_WITH_PROJECT)
.setDescription("description")
.setLocation(LOCATION)
.build();
private static final DatasetInfo OTHER_DATASET_INFO =
DatasetInfo.newBuilder(PROJECT, OTHER_DATASET)
.setAcl(ACCESS_RULES)
.setDescription("other description")
.setLocation(LOCATION)
.build();
private static final TableId TABLE_ID = TableId.of(DATASET, TABLE);
private static final TableId OTHER_TABLE_ID = TableId.of(PROJECT, DATASET, OTHER_TABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,20 @@ public class ITBigQueryTest {

private static final Set<String> PUBLIC_DATASETS =
ImmutableSet.of("github_repos", "hacker_news", "noaa_gsod", "samples", "usa_names");
private static final Map<String, String> PUBLIC_DATASETS_LOCATION =
ImmutableMap.<String, String>builder()
.put("github_repos", "US")
.put("hacker_news", "US")
.put("noaa_gsod", "US")
.put("samples", "US")
.put("usa_names", "US")
// Dataset url:
// https://console.cloud.google.com/bigquery?project=bigquery-public-data&ws=!1m4!1m3!3m2!1sbigquery-public-data!2sgnomAD_asiane1
.put("gnomAD_asiane1", "asia-northeast1")
// Dataset url:
// https://console.cloud.google.com/bigquery?project=bigquery-public-data&ws=!1m4!1m3!3m2!1sbigquery-public-data!2sgnomAD_eu
.put("gnomAD_eu", "EU")
.build();

private static final String PUBLIC_PROJECT = "bigquery-public-data";
private static final String PUBLIC_DATASET = "census_bureau_international";
Expand Down Expand Up @@ -961,11 +975,16 @@ public void testListDatasets() {
Page<Dataset> datasets = bigquery.listDatasets("bigquery-public-data");
Iterator<Dataset> iterator = datasets.iterateAll().iterator();
Set<String> datasetNames = new HashSet<>();
Map<String, String> datasetLocation = new HashMap<>();
while (iterator.hasNext()) {
datasetNames.add(iterator.next().getDatasetId().getDataset());
Dataset dataset = iterator.next();
String name = dataset.getDatasetId().getDataset();
datasetNames.add(name);
datasetLocation.put(name, dataset.getLocation());
}
for (String type : PUBLIC_DATASETS) {
assertTrue(datasetNames.contains(type));
assertEquals(PUBLIC_DATASETS_LOCATION.get(type), datasetLocation.get(type));
}
}

Expand Down Expand Up @@ -6530,11 +6549,16 @@ public void testUniverseDomainWithMatchingDomain() {
Page<Dataset> datasets = bigQuery.listDatasets("bigquery-public-data");
Iterator<Dataset> iterator = datasets.iterateAll().iterator();
Set<String> datasetNames = new HashSet<>();
Map<String, String> datasetLocation = new HashMap<>();
while (iterator.hasNext()) {
datasetNames.add(iterator.next().getDatasetId().getDataset());
Dataset dataset = iterator.next();
String name = dataset.getDatasetId().getDataset();
datasetNames.add(name);
datasetLocation.put(name, dataset.getLocation());
}
for (String type : PUBLIC_DATASETS) {
assertTrue(datasetNames.contains(type));
assertEquals(PUBLIC_DATASETS_LOCATION.get(type), datasetLocation.get(type));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ public void testListToDataset() {
.setId("project-id:dataset-id")
.setFriendlyName("friendly")
.setKind("bigquery#dataset")
.setLabels(Collections.singletonMap("foo", "bar"));
.setLabels(Collections.singletonMap("foo", "bar"))
.setLocation("test-region-1");
Dataset dataset = HttpBigQueryRpc.LIST_TO_DATASET.apply(listDataSet);

assertThat(dataset.getKind()).isEqualTo("bigquery#dataset");
assertThat(dataset.getId()).isEqualTo("project-id:dataset-id");
assertThat(dataset.getFriendlyName()).isEqualTo("friendly");
assertThat(dataset.getDatasetReference()).isEqualTo(datasetRef);
assertThat(dataset.getLabels()).containsExactly("foo", "bar");
assertThat(dataset.getLocation()).isEqualTo("test-region-1");
}
}