Skip to content

Commit 9651c64

Browse files
authored
Fix JDBC type validation to check for empty strings in Read and Write Postgres schema transform providers (apache#36103)
1 parent 246d955 commit 9651c64

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/ReadFromPostgresSchemaTransformProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected String jdbcType() {
5858
public @UnknownKeyFor @NonNull @Initialized SchemaTransform from(
5959
JdbcReadSchemaTransformConfiguration configuration) {
6060
String jdbcType = configuration.getJdbcType();
61-
if (jdbcType != null && !jdbcType.equals(jdbcType())) {
61+
if (jdbcType != null && !jdbcType.isEmpty() && !jdbcType.equals(jdbcType())) {
6262
throw new IllegalArgumentException(
6363
String.format("Wrong JDBC type. Expected '%s' but got '%s'", jdbcType(), jdbcType));
6464
}

sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/WriteToPostgresSchemaTransformProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected String jdbcType() {
5858
public @UnknownKeyFor @NonNull @Initialized SchemaTransform from(
5959
JdbcWriteSchemaTransformConfiguration configuration) {
6060
String jdbcType = configuration.getJdbcType();
61-
if (jdbcType != null && !jdbcType.equals(jdbcType())) {
61+
if (jdbcType != null && !jdbcType.isEmpty() && !jdbcType.equals(jdbcType())) {
6262
throw new IllegalArgumentException(
6363
String.format("Wrong JDBC type. Expected '%s' but got '%s'", jdbcType(), jdbcType));
6464
}

0 commit comments

Comments
 (0)