@@ -145,8 +145,9 @@ public class ITBigQueryStorageWriteClientTest {
145145 {165846896123456L /* 1975-04-04T12:34:56.123456Z */ , "1975-04-04T12:34:56.123456789000Z" }
146146 };
147147
148- // Arrow is a bit special in that timestamps are limited to nanoseconds precision.
149- // The data will be padded to fit into the higher precision columns.
148+ // Special case where users can use the Write API with Protobuf messages
149+ // The format is two fields: 1. Seconds from epoch and 2. Subsecond fractional (millis, micros,
150+ // nano, or pico). This test case is using picos sub-second fractional
150151 private static final Long [][] INPUT_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS =
151152 new Long [][] {
152153 {1735734896L , 123456789123L }, /* 2025-01-01T12:34:56.123456789123Z */
@@ -155,15 +156,15 @@ public class ITBigQueryStorageWriteClientTest {
155156 {165846896L , 123456789123L } /* 1975-04-04T12:34:56.123456789123Z */
156157 };
157158
158- // Arrow's higher precision column is padded with extra 0's if configured to return
159- // ISO as output for any picosecond enabled column.
160- private static final String [] EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_ISO_OUTPUT =
161- new String [] {
162- "2025-01-01T12:34:56.123456789123Z" ,
163- "2020-02-02T12:34:56.123456789123Z" ,
164- "1990-03-03T12:34:56.123456789123Z" ,
165- "1975-04-04T12:34:56.123456789123Z"
166- };
159+ // Expected ISO8601 output when using proto descriptors to write to BQ with pico precision
160+ private static final String []
161+ EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_HIGH_PRECISION_ISO_OUTPUT =
162+ new String [] {
163+ "2025-01-01T12:34:56.123456789123Z" ,
164+ "2020-02-02T12:34:56.123456789123Z" ,
165+ "1990-03-03T12:34:56.123456789123Z" ,
166+ "1975-04-04T12:34:56.123456789123Z"
167+ };
167168
168169 public static class StringWithSecondsNanos {
169170 public String foo ;
@@ -2453,7 +2454,7 @@ public void timestamp_protobufWrite_customMessage_higherPrecision()
24532454 createTimestampTable (tableName );
24542455
24552456 /*
2456- A sample protobuf format :
2457+ A sample protobuf format:
24572458 message Wrapper {
24582459 message TimestampPicos {
24592460 int64 seconds = 1;
@@ -2551,11 +2552,13 @@ public void timestamp_protobufWrite_customMessage_higherPrecision()
25512552 .map (x -> x .get (TIMESTAMP_HIGHER_PRECISION_COLUMN_NAME ).toString ())
25522553 .collect (Collectors .toList ());
25532554 assertEquals (
2554- EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_ISO_OUTPUT .length ,
2555+ EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_HIGH_PRECISION_ISO_OUTPUT .length ,
25552556 timestampHigherPrecision .size ());
2556- for (int i = 0 ; i < EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_ISO_OUTPUT .length ; i ++) {
2557+ for (int i = 0 ;
2558+ i < EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_HIGH_PRECISION_ISO_OUTPUT .length ;
2559+ i ++) {
25572560 assertEquals (
2558- EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_ISO_OUTPUT [i ],
2561+ EXPECTED_PROTO_DESCRIPTOR_WRITE_TIMESTAMPS_HIGH_PRECISION_ISO_OUTPUT [i ],
25592562 timestampHigherPrecision .get (i ));
25602563 }
25612564 }
0 commit comments