@@ -613,6 +613,7 @@ public class ITBigQueryTest {
613
613
private static final String LOAD_FILE_LARGE = "load_large.csv" ;
614
614
615
615
private static final String LOAD_FILE_FLEXIBLE_COLUMN_NAME = "load_flexible_column_name.csv" ;
616
+ private static final String LOAD_FILE_NULL = "load_null.csv" ;
616
617
private static final String JSON_LOAD_FILE = "load.json" ;
617
618
private static final String JSON_LOAD_FILE_BQ_RESULTSET = "load_bq_resultset.json" ;
618
619
private static final String JSON_LOAD_FILE_SIMPLE = "load_simple.json" ;
@@ -628,6 +629,7 @@ public class ITBigQueryTest {
628
629
private static final TableId TABLE_ID_FASTQUERY_BQ_RESULTSET =
629
630
TableId .of (DATASET , "fastquery_testing_bq_resultset" );
630
631
private static final String CSV_CONTENT = "StringValue1\n StringValue2\n " ;
632
+ private static final String CSV_CONTENT_NULL = "String\0 Value1\n " ;
631
633
private static final String CSV_CONTENT_FLEXIBLE_COLUMN = "name,&ersand\n row_name,1" ;
632
634
633
635
private static final String JSON_CONTENT =
@@ -1080,6 +1082,9 @@ public static void beforeClass() throws InterruptedException, IOException {
1080
1082
storage .create (
1081
1083
BlobInfo .newBuilder (BUCKET , LOAD_FILE ).setContentType ("text/plain" ).build (),
1082
1084
CSV_CONTENT .getBytes (StandardCharsets .UTF_8 ));
1085
+ storage .create (
1086
+ BlobInfo .newBuilder (BUCKET , LOAD_FILE_NULL ).setContentType ("text/plain" ).build (),
1087
+ CSV_CONTENT_NULL .getBytes (StandardCharsets .UTF_8 ));
1083
1088
storage .create (
1084
1089
BlobInfo .newBuilder (BUCKET , LOAD_FILE_FLEXIBLE_COLUMN_NAME )
1085
1090
.setContentType ("text/plain" )
@@ -6600,9 +6605,9 @@ public void testLocation() throws Exception {
6600
6605
}
6601
6606
6602
6607
@ Test
6603
- public void testPreserveAsciiControlCharacters ()
6608
+ public void testWriteChannelPreserveAsciiControlCharacters ()
6604
6609
throws InterruptedException , IOException , TimeoutException {
6605
- String destinationTableName = "test_preserve_ascii_control_characters " ;
6610
+ String destinationTableName = "test_write_channel_preserve_ascii_control_characters " ;
6606
6611
TableId tableId = TableId .of (DATASET , destinationTableName );
6607
6612
WriteChannelConfiguration configuration =
6608
6613
WriteChannelConfiguration .newBuilder (tableId )
@@ -6625,6 +6630,26 @@ public void testPreserveAsciiControlCharacters()
6625
6630
assertTrue (bigquery .delete (tableId ));
6626
6631
}
6627
6632
6633
+ @ Test
6634
+ public void testLoadJobPreserveAsciiControlCharacters () throws InterruptedException {
6635
+ String destinationTableName = "test_load_job_preserve_ascii_control_characters" ;
6636
+ TableId destinationTable = TableId .of (DATASET , destinationTableName );
6637
+
6638
+ try {
6639
+ LoadJobConfiguration configuration =
6640
+ LoadJobConfiguration .newBuilder (destinationTable , "gs://" + BUCKET + "/" + LOAD_FILE_NULL )
6641
+ .setFormatOptions (
6642
+ CsvOptions .newBuilder ().setPreserveAsciiControlCharacters (true ).build ())
6643
+ .setSchema (SIMPLE_SCHEMA )
6644
+ .build ();
6645
+ Job remoteLoadJob = bigquery .create (JobInfo .of (configuration ));
6646
+ remoteLoadJob = remoteLoadJob .waitFor ();
6647
+ assertNull (remoteLoadJob .getStatus ().getError ());
6648
+ } finally {
6649
+ assertTrue (bigquery .delete (destinationTable ));
6650
+ }
6651
+ }
6652
+
6628
6653
@ Test
6629
6654
public void testReferenceFileSchemaUriForAvro () {
6630
6655
try {
0 commit comments