@@ -613,6 +613,7 @@ public class ITBigQueryTest {
613613 private static final String LOAD_FILE_LARGE = "load_large.csv" ;
614614
615615 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" ;
616617 private static final String JSON_LOAD_FILE = "load.json" ;
617618 private static final String JSON_LOAD_FILE_BQ_RESULTSET = "load_bq_resultset.json" ;
618619 private static final String JSON_LOAD_FILE_SIMPLE = "load_simple.json" ;
@@ -628,6 +629,7 @@ public class ITBigQueryTest {
628629 private static final TableId TABLE_ID_FASTQUERY_BQ_RESULTSET =
629630 TableId .of (DATASET , "fastquery_testing_bq_resultset" );
630631 private static final String CSV_CONTENT = "StringValue1\n StringValue2\n " ;
632+ private static final String CSV_CONTENT_NULL = "String\0 Value1\n " ;
631633 private static final String CSV_CONTENT_FLEXIBLE_COLUMN = "name,&ersand\n row_name,1" ;
632634
633635 private static final String JSON_CONTENT =
@@ -1080,6 +1082,11 @@ public static void beforeClass() throws InterruptedException, IOException {
10801082 storage .create (
10811083 BlobInfo .newBuilder (BUCKET , LOAD_FILE ).setContentType ("text/plain" ).build (),
10821084 CSV_CONTENT .getBytes (StandardCharsets .UTF_8 ));
1085+ storage .create (
1086+ BlobInfo .newBuilder (BUCKET , LOAD_FILE_NULL )
1087+ .setContentType ("text/plain" )
1088+ .build (),
1089+ CSV_CONTENT_NULL .getBytes (StandardCharsets .UTF_8 ));
10831090 storage .create (
10841091 BlobInfo .newBuilder (BUCKET , LOAD_FILE_FLEXIBLE_COLUMN_NAME )
10851092 .setContentType ("text/plain" )
@@ -6600,9 +6607,9 @@ public void testLocation() throws Exception {
66006607 }
66016608
66026609 @ Test
6603- public void testPreserveAsciiControlCharacters ()
6610+ public void testWriteChannelPreserveAsciiControlCharacters ()
66046611 throws InterruptedException , IOException , TimeoutException {
6605- String destinationTableName = "test_preserve_ascii_control_characters " ;
6612+ String destinationTableName = "test_write_channel_preserve_ascii_control_characters " ;
66066613 TableId tableId = TableId .of (DATASET , destinationTableName );
66076614 WriteChannelConfiguration configuration =
66086615 WriteChannelConfiguration .newBuilder (tableId )
@@ -6625,6 +6632,27 @@ public void testPreserveAsciiControlCharacters()
66256632 assertTrue (bigquery .delete (tableId ));
66266633 }
66276634
6635+ @ Test
6636+ public void testLoadJobPreserveAsciiControlCharacters ()
6637+ throws InterruptedException {
6638+ String destinationTableName = "test_load_job_preserve_ascii_control_characters" ;
6639+ TableId destinationTable = TableId .of (DATASET , destinationTableName );
6640+
6641+ try {
6642+ LoadJobConfiguration configuration =
6643+ LoadJobConfiguration .newBuilder (destinationTable , "gs://" + BUCKET + "/" + LOAD_FILE_NULL )
6644+ .setFormatOptions (
6645+ CsvOptions .newBuilder ().setPreserveAsciiControlCharacters (true ).build ())
6646+ .setSchema (SIMPLE_SCHEMA )
6647+ .build ();
6648+ Job remoteLoadJob = bigquery .create (JobInfo .of (configuration ));
6649+ remoteLoadJob = remoteLoadJob .waitFor ();
6650+ assertNull (remoteLoadJob .getStatus ().getError ());
6651+ } finally {
6652+ assertTrue (bigquery .delete (destinationTable ));
6653+ }
6654+ }
6655+
66286656 @ Test
66296657 public void testReferenceFileSchemaUriForAvro () {
66306658 try {
0 commit comments