use of com.google.cloud.bigquery.Dataset in project google-cloud-java by GoogleCloudPlatform.
the class DatasetSnippets method updateDataset.
/**
* Example of updating a dataset.
*/
// [TARGET update(DatasetOption...)]
// [VARIABLE "my_friendly_name"]
public Dataset updateDataset(String friendlyName) {
// [START update]
Builder builder = dataset.toBuilder();
builder.setFriendlyName(friendlyName);
Dataset updatedDataset = builder.build().update();
// [END update]
return updatedDataset;
}
use of com.google.cloud.bigquery.Dataset in project google-cloud-java by GoogleCloudPlatform.
the class BigQuerySnippets method getDatasetFromId.
/**
* Example of getting a dataset.
*/
// [TARGET getDataset(DatasetId, DatasetOption...)]
// [VARIABLE "my_project_id"]
// [VARIABLE "my_dataset_name"]
public Dataset getDatasetFromId(String projectId, String datasetName) {
// [START getDatasetFromId]
DatasetId datasetId = DatasetId.of(projectId, datasetName);
Dataset dataset = bigquery.getDataset(datasetId);
// [END getDatasetFromId]
return dataset;
}
use of com.google.cloud.bigquery.Dataset in project google-cloud-java by GoogleCloudPlatform.
the class BigQuerySnippets method updateDataset.
/**
* Example of updating a dataset by changing its friendly name.
*/
// [TARGET update(DatasetInfo, DatasetOption...)]
// [VARIABLE "my_dataset_name"]
// [VARIABLE "some_new_friendly_name"]
public Dataset updateDataset(String datasetName, String newFriendlyName) {
// [START updateDataset]
Dataset oldDataset = bigquery.getDataset(datasetName);
DatasetInfo datasetInfo = oldDataset.toBuilder().setFriendlyName(newFriendlyName).build();
Dataset newDataset = bigquery.update(datasetInfo);
// [END updateDataset]
return newDataset;
}
use of com.google.cloud.bigquery.Dataset in project google-cloud-java by GoogleCloudPlatform.
the class ITDatasetSnippets method testUpdate.
@Test
public void testUpdate() {
assertNull(dataset.getFriendlyName());
Dataset updatedDataset = datasetSnippets.updateDataset(FRIENDLY_NAME);
assertEquals(FRIENDLY_NAME, updatedDataset.getFriendlyName());
}
use of com.google.cloud.bigquery.Dataset in project google-cloud-java by GoogleCloudPlatform.
the class BigQuerySnippets method createDataset.
/**
* Example of creating a dataset.
*/
// [TARGET create(DatasetInfo, DatasetOption...)]
// [VARIABLE "my_dataset_name"]
public Dataset createDataset(String datasetName) {
// [START createDataset]
Dataset dataset = null;
DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName).build();
try {
// the dataset was created
dataset = bigquery.create(datasetInfo);
} catch (BigQueryException e) {
// the dataset was not created
}
// [END createDataset]
return dataset;
}
Aggregations