Skip to content

Commit

Permalink
0005035: Big Query support for bulk loading data with commas
Browse files Browse the repository at this point in the history
Description
  • Loading branch information
joshhicks committed Jun 21, 2021
1 parent c931c16 commit 507c1cd
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -20,6 +20,7 @@
import org.jumpmind.symmetric.service.IParameterService;

import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.CsvOptions;
import com.google.cloud.bigquery.FormatOptions;
import com.google.cloud.bigquery.Job;
import com.google.cloud.bigquery.JobId;
Expand All @@ -39,7 +40,7 @@ public BigQueryBulkDatabaseWriter(IDatabasePlatform symmetricPlatform, IDatabase
throws FileNotFoundException, IOException {
super(symmetricPlatform, targetPlatform, tablePrefix, stagingManager, filters, errorHandlers, parameterService,
securityService, writerSettings);
fieldTerminator = ",";
fieldTerminator = "||";
bigquery = bq;
}

Expand All @@ -49,8 +50,11 @@ public void loadToCloudDatabase() throws SQLException {
File csvPath = this.stagedInputFile.getFile();

TableId tableId = TableId.of(this.targetTable.getSchema(), this.targetTable.getName());
CsvOptions csvOptions = CsvOptions.newBuilder().setFieldDelimiter(fieldTerminator).build();

WriteChannelConfiguration writeChannelConfiguration =
WriteChannelConfiguration.newBuilder(tableId).setFormatOptions(FormatOptions.csv()).setAutodetect(false).setDestinationTable(tableId).build();
WriteChannelConfiguration.newBuilder(tableId).setFormatOptions(csvOptions).setAutodetect(false).setDestinationTable(tableId).build();

// The location must be specified; other fields can be auto-detected.
JobId jobId = JobId.newBuilder()
.setLocation(bigquery.getOptions().getLocation())
Expand Down

0 comments on commit 507c1cd

Please sign in to comment.