@@ -38,12 +38,14 @@ public class SnowflakeCopyBatchInsert implements BatchInsert {
3838 private long totalRows ;
3939 private int fileCount ;
4040 private List <Future <Void >> uploadAndCopyFutures ;
41+ private boolean emptyFieldAsNull ;
4142
4243 public SnowflakeCopyBatchInsert (
4344 JdbcOutputConnector connector ,
4445 StageIdentifier stageIdentifier ,
4546 boolean deleteStageFile ,
46- int maxUploadRetries )
47+ int maxUploadRetries ,
48+ boolean emptyFieldAsNull )
4749 throws IOException {
4850 this .index = 0 ;
4951 openNewFile ();
@@ -53,6 +55,7 @@ public SnowflakeCopyBatchInsert(
5355 this .deleteStageFile = deleteStageFile ;
5456 this .uploadAndCopyFutures = new ArrayList ();
5557 this .maxUploadRetries = maxUploadRetries ;
58+ this .emptyFieldAsNull = emptyFieldAsNull ;
5659 }
5760
5861 @ Override
@@ -260,7 +263,7 @@ public void flush() throws IOException, SQLException {
260263 Future <Void > uploadFuture = executorService .submit (uploadTask );
261264 uploadAndCopyFutures .add (uploadFuture );
262265
263- CopyTask copyTask = new CopyTask (uploadFuture , snowflakeStageFileName );
266+ CopyTask copyTask = new CopyTask (uploadFuture , snowflakeStageFileName , emptyFieldAsNull );
264267 uploadAndCopyFutures .add (executorService .submit (copyTask ));
265268
266269 fileCount ++;
@@ -393,10 +396,13 @@ public Void call() throws IOException, SQLException, InterruptedException {
393396 private class CopyTask implements Callable <Void > {
394397 private final Future <Void > uploadFuture ;
395398 private final String snowflakeStageFileName ;
399+ private final boolean emptyFieldAsNull ;
396400
397- public CopyTask (Future <Void > uploadFuture , String snowflakeStageFileName ) {
401+ public CopyTask (
402+ Future <Void > uploadFuture , String snowflakeStageFileName , boolean emptyFieldAsNull ) {
398403 this .uploadFuture = uploadFuture ;
399404 this .snowflakeStageFileName = snowflakeStageFileName ;
405+ this .emptyFieldAsNull = emptyFieldAsNull ;
400406 }
401407
402408 public Void call () throws SQLException , InterruptedException , ExecutionException {
@@ -408,7 +414,12 @@ public Void call() throws SQLException, InterruptedException, ExecutionException
408414 logger .info ("Running COPY from file {}" , snowflakeStageFileName );
409415
410416 long startTime = System .currentTimeMillis ();
411- con .runCopy (tableIdentifier , stageIdentifier , snowflakeStageFileName , delimiterString );
417+ con .runCopy (
418+ tableIdentifier ,
419+ stageIdentifier ,
420+ snowflakeStageFileName ,
421+ delimiterString ,
422+ emptyFieldAsNull );
412423
413424 double seconds = (System .currentTimeMillis () - startTime ) / 1000.0 ;
414425
0 commit comments