in services/library/src/main/java/com/google/cloud/pso/bq_snapshot_manager/services/bq/BigQueryServiceImpl.java [96:136]
public void exportToGCS(
String jobId,
TableSpec sourceTable,
String gcsDestinationUri,
GCSSnapshotFormat exportFormat,
@Nullable String csvFieldDelimiter,
@Nullable Boolean csvPrintHeader,
@Nullable Boolean useAvroLogicalTypes,
String trackingId,
Map<String, String> jobLabels
) throws InterruptedException {
Tuple<String, String> formatAndCompression = GCSSnapshotFormat.getFormatAndCompression(exportFormat);
ExtractJobConfiguration.Builder extractConfigurationBuilder = ExtractJobConfiguration
.newBuilder(sourceTable.toTableId(), gcsDestinationUri)
.setLabels(jobLabels)
.setFormat(formatAndCompression.x());
// check if compression is required
if (formatAndCompression.y() != null) {
extractConfigurationBuilder.setCompression(formatAndCompression.y());
}
// set optional fields
if (csvFieldDelimiter != null) {
extractConfigurationBuilder.setFieldDelimiter(csvFieldDelimiter);
}
if (csvPrintHeader != null) {
extractConfigurationBuilder.setPrintHeader(csvPrintHeader);
}
if (useAvroLogicalTypes != null) {
extractConfigurationBuilder.setUseAvroLogicalTypes(useAvroLogicalTypes);
}
// async call to create an export job
bigQuery.create(JobInfo
.newBuilder(extractConfigurationBuilder.build())
.setJobId(JobId.of(jobId))
.build());
}