diff --git a/sdks/java/io/google-cloud-platform/build.gradle b/sdks/java/io/google-cloud-platform/build.gradle index c8cc9958e2f3..1555297ab10c 100644 --- a/sdks/java/io/google-cloud-platform/build.gradle +++ b/sdks/java/io/google-cloud-platform/build.gradle @@ -30,6 +30,11 @@ applyJavaNature( description = "Apache Beam :: SDKs :: Java :: IO :: Google Cloud Platform" ext.summary = "IO library to read and write Google Cloud Platform systems from Beam." +tasks.withType(Test).configureEach { + // Open java.nio for Apache Arrow direct memory access under Java 17+ + jvmArgs '--add-opens=java.base/java.nio=ALL-UNNAMED' +} + dependencies { implementation(enforcedPlatform(library.java.google_cloud_platform_libraries_bom)) implementation project(path: ":model:pipeline", configuration: "shadow") diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProtoTest.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProtoTest.java index 88bf3ef3f14d..50fb2c073621 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProtoTest.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProtoTest.java @@ -62,6 +62,11 @@ /** Unit tests form {@link BeamRowToStorageApiProto}. */ @RunWith(JUnit4.class) public class BeamRowToStorageApiProtoTest { + private static final LocalTime TEST_TIME_MICROS = LocalTime.of(12, 30, 45, 123_456_000); + private static final LocalDateTime TEST_DATETIME_MICROS = + LocalDateTime.of(2024, 1, 15, 12, 30, 45, 123_456_000); + private static final java.time.Instant TEST_INSTANT_MICROS = + java.time.Instant.parse("2024-01-15T12:30:45.123456Z"); private static final java.time.Instant TEST_INSTANT_NANOS = java.time.Instant.parse("2024-01-15T12:30:45.123456789Z"); @@ -254,9 +259,9 @@ public class BeamRowToStorageApiProtoTest { .withFieldValue("arrayNullValue", null) .withFieldValue("iterableValue", ImmutableList.of("blue", "red", "two", "one")) .withFieldValue("sqlDateValue", LocalDate.now(ZoneOffset.UTC)) - .withFieldValue("sqlTimeValue", LocalTime.now(ZoneOffset.UTC)) - .withFieldValue("sqlDatetimeValue", LocalDateTime.now(ZoneOffset.UTC)) - .withFieldValue("sqlTimestampValue", java.time.Instant.now().plus(123, ChronoUnit.MICROS)) + .withFieldValue("sqlTimeValue", TEST_TIME_MICROS) + .withFieldValue("sqlDatetimeValue", TEST_DATETIME_MICROS) + .withFieldValue("sqlTimestampValue", TEST_INSTANT_MICROS) .withFieldValue("enumValue", TEST_ENUM.valueOf("RED")) .build(); private static final Map BASE_PROTO_EXPECTED_FIELDS =