@@ -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,9 @@ 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 ).setContentType ("text/plain" ).build (),
1087+ CSV_CONTENT_NULL .getBytes (StandardCharsets .UTF_8 ));
10831088 storage .create (
10841089 BlobInfo .newBuilder (BUCKET , LOAD_FILE_FLEXIBLE_COLUMN_NAME )
10851090 .setContentType ("text/plain" )
@@ -6600,9 +6605,9 @@ public void testLocation() throws Exception {
66006605 }
66016606
66026607 @ Test
6603- public void testPreserveAsciiControlCharacters ()
6608+ public void testWriteChannelPreserveAsciiControlCharacters ()
66046609 throws InterruptedException , IOException , TimeoutException {
6605- String destinationTableName = "test_preserve_ascii_control_characters " ;
6610+ String destinationTableName = "test_write_channel_preserve_ascii_control_characters " ;
66066611 TableId tableId = TableId .of (DATASET , destinationTableName );
66076612 WriteChannelConfiguration configuration =
66086613 WriteChannelConfiguration .newBuilder (tableId )
@@ -6625,6 +6630,26 @@ public void testPreserveAsciiControlCharacters()
66256630 assertTrue (bigquery .delete (tableId ));
66266631 }
66276632
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+
66286653 @ Test
66296654 public void testReferenceFileSchemaUriForAvro () {
66306655 try {
0 commit comments