Dataset toPb() { Dataset datasetPb = new Dataset(); datasetPb.setDatasetReference(datasetId.toPb()); datasetPb.setCreationTime(creationTime); datasetPb.setDefaultTableExpirationMs(defaultTableLifetime); datasetPb.setDescription(description); datasetPb.setEtag(etag); datasetPb.setFriendlyName(friendlyName); datasetPb.setId(generatedId); datasetPb.setLastModifiedTime(lastModified); datasetPb.setLocation(location); datasetPb.setSelfLink(selfLink); if (acl != null) { datasetPb.setAccess( Lists.transform( acl, new Function<Acl, Dataset.Access>() { @Override public Dataset.Access apply(Acl acl) { return acl.toPb(); } })); } datasetPb.setLabels(labels.toPb()); return datasetPb; }
private Dataset dataset(String defaultProjectId, DatasetConfig config) { return new Dataset() .setDatasetReference(new DatasetReference() .setProjectId(config.project().or(defaultProjectId)) .setDatasetId(config.id())) .setFriendlyName(config.friendly_name().orNull()) .setDefaultTableExpirationMs(config.default_table_expiration().transform(d -> d.getDuration().toMillis()).orNull()) .setLocation(config.location().orNull()) .setAccess(config.access().orNull()) .setLabels(config.labels().orNull()); }
private void createDataset(String datasetId, @Nullable String location) throws IOException, InterruptedException { Dataset dataset = new Dataset(); DatasetReference reference = new DatasetReference(); reference.setProjectId(projectId); reference.setDatasetId(datasetId); dataset.setDatasetReference(reference); if (location != null) { dataset.setLocation(location); } executeWithBackOff( client.datasets().insert(projectId, dataset), String.format( "Error when trying to create the temporary dataset %s in project %s.", datasetId, projectId)); }
dataset.setLocation(location);
Dataset toPb() { Dataset datasetPb = new Dataset(); datasetPb.setDatasetReference(datasetId.toPb()); datasetPb.setCreationTime(creationTime); datasetPb.setDefaultTableExpirationMs(defaultTableLifetime); datasetPb.setDescription(description); datasetPb.setEtag(etag); datasetPb.setFriendlyName(friendlyName); datasetPb.setId(generatedId); datasetPb.setLastModifiedTime(lastModified); datasetPb.setLocation(location); datasetPb.setSelfLink(selfLink); if (acl != null) { datasetPb.setAccess(Lists.transform(acl, new Function<Acl, Dataset.Access>() { @Override public Dataset.Access apply(Acl acl) { return acl.toPb(); } })); } return datasetPb; }
Dataset toPb() { Dataset datasetPb = new Dataset(); datasetPb.setDatasetReference(datasetId.toPb()); datasetPb.setCreationTime(creationTime); datasetPb.setDefaultTableExpirationMs(defaultTableLifetime); datasetPb.setDescription(description); datasetPb.setEtag(etag); datasetPb.setFriendlyName(friendlyName); datasetPb.setId(generatedId); datasetPb.setLastModifiedTime(lastModified); datasetPb.setLocation(location); datasetPb.setSelfLink(selfLink); if (acl != null) { datasetPb.setAccess(Lists.transform(acl, new Function<Acl, Dataset.Access>() { @Override public Dataset.Access apply(Acl acl) { return acl.toPb(); } })); } return datasetPb; }
Dataset toPb() { Dataset datasetPb = new Dataset(); datasetPb.setDatasetReference(datasetId.toPb()); datasetPb.setCreationTime(creationTime); datasetPb.setDefaultTableExpirationMs(defaultTableLifetime); datasetPb.setDescription(description); datasetPb.setEtag(etag); datasetPb.setFriendlyName(friendlyName); datasetPb.setId(generatedId); datasetPb.setLastModifiedTime(lastModified); datasetPb.setLocation(location); datasetPb.setSelfLink(selfLink); if (acl != null) { datasetPb.setAccess( Lists.transform( acl, new Function<Acl, Dataset.Access>() { @Override public Dataset.Access apply(Acl acl) { return acl.toPb(); } })); } datasetPb.setLabels(labels.toPb()); return datasetPb; }
/** * Creates the temporary dataset that will contain all of the task work tables. * * @param context the job's context. * @throws IOException on IO Error. */ @Override public void setupJob(JobContext context) throws IOException { logger.atFine().log("setupJob(%s)", lazy(() -> HadoopToStringUtil.toString(context))); // Create dataset. DatasetReference datasetReference = new DatasetReference(); datasetReference.setProjectId(tempTableRef.getProjectId()); datasetReference.setDatasetId(tempTableRef.getDatasetId()); Dataset tempDataset = new Dataset(); tempDataset.setDatasetReference(datasetReference); tempDataset.setLocation(getLocation(context)); // Insert dataset into Bigquery. Bigquery.Datasets datasets = bigQueryHelper.getRawBigquery().datasets(); // TODO(user): Maybe allow the dataset to exist already instead of throwing 409 here. logger.atFine().log( "Creating temporary dataset '%s' for project '%s'", tempTableRef.getDatasetId(), tempTableRef.getProjectId()); // NB: Even though this "insert" makes it look like we can specify a different projectId than // the one which owns the dataset, it actually has to match. datasets.insert(tempTableRef.getProjectId(), tempDataset).execute(); }