Search in sources :

Example 6 with DatasetId

use of com.google.cloud.bigquery.DatasetId in project java-docs-samples by GoogleCloudPlatform.

the class QuickstartSampleIT method deleteMyNewDataset.

private static final void deleteMyNewDataset() {
    BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
    String datasetName = "my_new_dataset";
    DatasetId datasetId = DatasetId.of(datasetName);
    DatasetDeleteOption deleteContents = DatasetDeleteOption.deleteContents();
    bigquery.delete(datasetId, deleteContents);
}
Also used : DatasetDeleteOption(com.google.cloud.bigquery.BigQuery.DatasetDeleteOption) BigQuery(com.google.cloud.bigquery.BigQuery) DatasetId(com.google.cloud.bigquery.DatasetId)

Example 7 with DatasetId

use of com.google.cloud.bigquery.DatasetId in project components by Talend.

the class BigQueryBeamRuntimeTestIT method cleanDataset.

@AfterClass
public static void cleanDataset() {
    BigQuery bigquery = BigQueryConnection.createClient(createDatastore());
    DatasetId datasetId = DatasetId.of(BigQueryTestConstants.PROJECT, datasetName);
    bigquery.delete(datasetId, BigQuery.DatasetDeleteOption.deleteContents());
}
Also used : BigQuery(com.google.cloud.bigquery.BigQuery) DatasetId(com.google.cloud.bigquery.DatasetId) AfterClass(org.junit.AfterClass)

Example 8 with DatasetId

use of com.google.cloud.bigquery.DatasetId in project java-docs-samples by GoogleCloudPlatform.

the class QuerySampleIT method createTestDataset.

private static final void createTestDataset() {
    BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
    DatasetId datasetId = DatasetId.of(TEST_DATASET);
    bigquery.create(DatasetInfo.newBuilder(datasetId).build());
}
Also used : BigQuery(com.google.cloud.bigquery.BigQuery) DatasetId(com.google.cloud.bigquery.DatasetId)

Example 9 with DatasetId

use of com.google.cloud.bigquery.DatasetId in project presto by prestodb.

the class BigQueryClient method createDestinationTable.

protected TableId createDestinationTable(TableId tableId) {
    String project = viewMaterializationProject.orElse(tableId.getProject());
    String dataset = viewMaterializationDataset.orElse(tableId.getDataset());
    DatasetId datasetId = mapIfNeeded(project, dataset);
    return TableId.of(datasetId.getProject(), datasetId.getDataset(), createTableName());
}
Also used : DatasetId(com.google.cloud.bigquery.DatasetId)

Example 10 with DatasetId

use of com.google.cloud.bigquery.DatasetId in project presto by prestodb.

the class BigQueryClient method listTables.

protected Iterable<Table> listTables(DatasetId datasetId, TableDefinition.Type... types) {
    Set<TableDefinition.Type> allowedTypes = ImmutableSet.copyOf(types);
    DatasetId bigQueryDatasetId = datasetIds.getOrDefault(datasetId, datasetId);
    Iterable<Table> allTables = bigQuery.listTables(bigQueryDatasetId).iterateAll();
    allTables.forEach(table -> addTableMappingIfNeeded(bigQueryDatasetId, table));
    return StreamSupport.stream(allTables.spliterator(), false).filter(table -> allowedTypes.contains(table.getDefinition().getType())).collect(toImmutableList());
}
Also used : TableId(com.google.cloud.bigquery.TableId) BigQueryException(com.google.cloud.bigquery.BigQueryException) DatasetId(com.google.cloud.bigquery.DatasetId) Iterators(com.google.common.collect.Iterators) BigQuery(com.google.cloud.bigquery.BigQuery) ConcurrentMap(java.util.concurrent.ConcurrentMap) Dataset(com.google.cloud.bigquery.Dataset) Objects.requireNonNull(java.util.Objects.requireNonNull) Job(com.google.cloud.bigquery.Job) StreamSupport(java.util.stream.StreamSupport) TableResult(com.google.cloud.bigquery.TableResult) Table(com.google.cloud.bigquery.Table) ENGLISH(java.util.Locale.ENGLISH) BIGQUERY_QUERY_FAILED_UNKNOWN(com.facebook.presto.plugin.bigquery.BigQueryErrorCode.BIGQUERY_QUERY_FAILED_UNKNOWN) TableDefinition(com.google.cloud.bigquery.TableDefinition) ImmutableSet(com.google.common.collect.ImmutableSet) JobInfo(com.google.cloud.bigquery.JobInfo) Iterator(java.util.Iterator) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) QueryJobConfiguration(com.google.cloud.bigquery.QueryJobConfiguration) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) List(java.util.List) UUID.randomUUID(java.util.UUID.randomUUID) Optional(java.util.Optional) TableInfo(com.google.cloud.bigquery.TableInfo) Table(com.google.cloud.bigquery.Table) DatasetId(com.google.cloud.bigquery.DatasetId)

Aggregations

DatasetId (com.google.cloud.bigquery.DatasetId)15 BigQuery (com.google.cloud.bigquery.BigQuery)9 Dataset (com.google.cloud.bigquery.Dataset)3 Table (com.google.cloud.bigquery.Table)3 TableDefinition (com.google.cloud.bigquery.TableDefinition)2 TableId (com.google.cloud.bigquery.TableId)2 AfterClass (org.junit.AfterClass)2 BeforeClass (org.junit.BeforeClass)2 BIGQUERY_QUERY_FAILED_UNKNOWN (com.facebook.presto.plugin.bigquery.BigQueryErrorCode.BIGQUERY_QUERY_FAILED_UNKNOWN)1 DatasetDeleteOption (com.google.cloud.bigquery.BigQuery.DatasetDeleteOption)1 BigQueryException (com.google.cloud.bigquery.BigQueryException)1 Job (com.google.cloud.bigquery.Job)1 JobInfo (com.google.cloud.bigquery.JobInfo)1 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)1 StandardTableDefinition (com.google.cloud.bigquery.StandardTableDefinition)1 TableInfo (com.google.cloud.bigquery.TableInfo)1 TableResult (com.google.cloud.bigquery.TableResult)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterators (com.google.common.collect.Iterators)1