Search in sources :

Example 11 with DatasetId

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

the class BigQueryClient method addDataSetMappingIfNeeded.

private Dataset addDataSetMappingIfNeeded(Dataset dataset) {
    DatasetId bigQueryDatasetId = dataset.getDatasetId();
    DatasetId prestoDatasetId = DatasetId.of(bigQueryDatasetId.getProject(), bigQueryDatasetId.getDataset().toLowerCase(ENGLISH));
    datasetIds.putIfAbsent(prestoDatasetId, bigQueryDatasetId);
    return dataset;
}
Also used : DatasetId(com.google.cloud.bigquery.DatasetId)

Example 12 with DatasetId

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

the class BigQueryBeamRuntimeTestIT method initDataset.

@BeforeClass
public static void initDataset() throws IOException {
    BigQuery bigquery = BigQueryConnection.createClient(createDatastore());
    DatasetId datasetId = DatasetId.of(BigQueryTestConstants.PROJECT, datasetName);
    bigquery.create(DatasetInfo.of(datasetId));
}
Also used : BigQuery(com.google.cloud.bigquery.BigQuery) DatasetId(com.google.cloud.bigquery.DatasetId) BeforeClass(org.junit.BeforeClass)

Example 13 with DatasetId

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

the class BigQueryDatasetRuntimeTestIT method cleanDatasetAndTable.

@AfterClass
public static void cleanDatasetAndTable() {
    BigQuery bigquery = BigQueryConnection.createClient(createDatastore());
    for (String dataset : datasets) {
        DatasetId datasetId = DatasetId.of(BigQueryTestConstants.PROJECT, dataset);
        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 14 with DatasetId

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

the class BigQueryDatasetRuntimeTestIT method initDatasetAndTable.

@BeforeClass
public static void initDatasetAndTable() throws IOException {
    BigQuery bigquery = BigQueryConnection.createClient(createDatastore());
    for (String dataset : datasets) {
        DatasetId datasetId = DatasetId.of(BigQueryTestConstants.PROJECT, dataset);
        bigquery.create(DatasetInfo.of(datasetId));
    }
    for (String table : tables) {
        TableDefinition tableDefinition = StandardTableDefinition.of(Schema.of(Field.of("test", Field.Type.string())));
        TableId tableId = TableId.of(BigQueryTestConstants.PROJECT, datasets.get(0), table);
        bigquery.create(TableInfo.of(tableId, tableDefinition));
    }
}
Also used : TableId(com.google.cloud.bigquery.TableId) BigQuery(com.google.cloud.bigquery.BigQuery) TableDefinition(com.google.cloud.bigquery.TableDefinition) StandardTableDefinition(com.google.cloud.bigquery.StandardTableDefinition) DatasetId(com.google.cloud.bigquery.DatasetId) BeforeClass(org.junit.BeforeClass)

Example 15 with DatasetId

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

the class BigQueryDatasetRuntime method listTables.

@Override
public Set<String> listTables() throws IOException {
    BigQuery bigquery = BigQueryConnection.createClient(properties.getDatastoreProperties());
    DatasetId datasetId = DatasetId.of(properties.getDatastoreProperties().projectName.getValue(), properties.bqDataset.getValue());
    Page<Table> tables = bigquery.listTables(datasetId, BigQuery.TableListOption.pageSize(100));
    Set<String> tablesName = new HashSet<>();
    Iterator<Table> tableIterator = tables.iterateAll();
    while (tableIterator.hasNext()) {
        tablesName.add(tableIterator.next().getTableId().getTable());
    }
    return tablesName;
}
Also used : BigQuery(com.google.cloud.bigquery.BigQuery) Table(com.google.cloud.bigquery.Table) DatasetId(com.google.cloud.bigquery.DatasetId) HashSet(java.util.HashSet)

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