use of com.google.cloud.bigquery.TableId in project presto by prestodb.
the class BigQuerySplitManager method getSplits.
@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingContext splitSchedulingContext) {
BigQueryTableLayoutHandle bigQueryTableLayoutHandle = (BigQueryTableLayoutHandle) layout;
BigQueryTableHandle bigQueryTableHandle = bigQueryTableLayoutHandle.getTable();
TableId tableId = bigQueryTableHandle.getTableId();
int actualParallelism = parallelism.orElse(nodeManager.getRequiredWorkerNodes().size());
Optional<String> filter = Optional.empty();
List<BigQuerySplit> splits = isEmptyProjectionIsRequired(bigQueryTableHandle.getProjectedColumns()) ? createEmptyProjection(tableId, actualParallelism, filter) : readFromBigQuery(tableId, bigQueryTableHandle.getProjectedColumns(), actualParallelism, filter);
return new FixedSplitSource(splits);
}
use of com.google.cloud.bigquery.TableId in project presto by prestodb.
the class BigQueryClient method addTableMappingIfNeeded.
private void addTableMappingIfNeeded(DatasetId datasetID, Table table) {
TableId bigQueryTableId = table.getTableId();
TableId prestoTableId = TableId.of(datasetID.getProject(), datasetID.getDataset(), createTableName());
tableIds.putIfAbsent(bigQueryTableId, prestoTableId);
}
use of com.google.cloud.bigquery.TableId in project beam by apache.
the class BigQueryClient method insertAll.
/**
* Inserts multiple rows of the same schema to a BigQuery table.
*/
public void insertAll(Collection<Map<String, ?>> rows, String table) {
TableId tableId = TableId.of(projectId, dataset, table);
InsertAllRequest.Builder builder = InsertAllRequest.newBuilder(tableId);
for (Map<String, ?> row : rows) {
builder.addRow(row);
}
InsertAllResponse response = client.insertAll(builder.build());
handleBigQueryResponseExceptions(response);
}
use of com.google.cloud.bigquery.TableId in project beam by apache.
the class BigQueryIOIT method tearDown.
@AfterClass
public static void tearDown() {
BigQueryOptions options = BigQueryOptions.newBuilder().build();
BigQuery client = options.getService();
TableId tableId = TableId.of(options.getProjectId(), testBigQueryDataset, testBigQueryTable);
client.delete(tableId);
}
use of com.google.cloud.bigquery.TableId in project google-cloud-java by GoogleCloudPlatform.
the class ITBigQueryTest method testExtractJob.
@Test
public void testExtractJob() throws InterruptedException, TimeoutException {
String tableName = "test_export_job_table";
TableId destinationTable = TableId.of(DATASET, tableName);
LoadJobConfiguration configuration = LoadJobConfiguration.newBuilder(destinationTable, "gs://" + BUCKET + "/" + LOAD_FILE).setSchema(SIMPLE_SCHEMA).build();
Job remoteLoadJob = bigquery.create(JobInfo.of(configuration));
remoteLoadJob = remoteLoadJob.waitFor();
assertNull(remoteLoadJob.getStatus().getError());
ExtractJobConfiguration extractConfiguration = ExtractJobConfiguration.newBuilder(destinationTable, "gs://" + BUCKET + "/" + EXTRACT_FILE).setPrintHeader(false).build();
Job remoteExtractJob = bigquery.create(JobInfo.of(extractConfiguration));
remoteExtractJob = remoteExtractJob.waitFor();
assertNull(remoteExtractJob.getStatus().getError());
assertEquals(CSV_CONTENT, new String(storage.readAllBytes(BUCKET, EXTRACT_FILE), StandardCharsets.UTF_8));
assertTrue(bigquery.delete(DATASET, tableName));
}
Aggregations