Skip to content

Commit e3293e2

Browse files
authored
Minor changes on Managed JDBCIO (#36339)
1 parent b5a0495 commit e3293e2

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

sdks/java/expansion-service/container/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ WORKDIR /opt/apache/beam
2828
COPY target/avro.jar jars/
2929
COPY target/beam-sdks-java-io-expansion-service.jar jars/
3030
COPY target/beam-sdks-java-io-google-cloud-platform-expansion-service.jar jars/
31-
COPY target/beam-sdks-java-extensions-schemaio-expansion-service.jar jars/
3231

3332
# Copy licenses
3433
COPY target/LICENSE /opt/apache/beam/

sdks/java/extensions/schemaio-expansion-service/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ task runExpansionService (type: JavaExec) {
7676
classpath = sourceSets.test.runtimeClasspath
7777
args = [project.findProperty("constructionService.port") ?: "8097"]
7878
}
79+
80+
shadowJar {
81+
manifest {
82+
attributes(["Multi-Release": true])
83+
}
84+
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,18 @@ protected String jdbcType() {
5959
JdbcReadSchemaTransformConfiguration configuration) {
6060
String jdbcType = configuration.getJdbcType();
6161
if (jdbcType != null && !jdbcType.isEmpty() && !jdbcType.equals(jdbcType())) {
62-
throw new IllegalArgumentException(
63-
String.format("Wrong JDBC type. Expected '%s' but got '%s'", jdbcType(), jdbcType));
62+
LOG.warn(
63+
"Wrong JDBC type. Expected '{}' but got '{}'. Overriding with '{}'.",
64+
jdbcType(),
65+
jdbcType,
66+
jdbcType());
67+
configuration = configuration.toBuilder().setJdbcType(jdbcType()).build();
6468
}
6569

6670
List<@org.checkerframework.checker.nullness.qual.Nullable String> connectionInitSql =
6771
configuration.getConnectionInitSql();
6872
if (connectionInitSql != null && !connectionInitSql.isEmpty()) {
69-
LOG.warn("Postgres does not support connectionInitSql, ignoring.");
73+
throw new IllegalArgumentException("Postgres does not support connectionInitSql.");
7074
}
7175

7276
Boolean disableAutoCommit = configuration.getDisableAutoCommit();

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,18 @@ protected String jdbcType() {
5959
JdbcWriteSchemaTransformConfiguration configuration) {
6060
String jdbcType = configuration.getJdbcType();
6161
if (jdbcType != null && !jdbcType.isEmpty() && !jdbcType.equals(jdbcType())) {
62-
throw new IllegalArgumentException(
63-
String.format("Wrong JDBC type. Expected '%s' but got '%s'", jdbcType(), jdbcType));
62+
LOG.warn(
63+
"Wrong JDBC type. Expected '{}' but got '{}'. Overriding with '{}'.",
64+
jdbcType(),
65+
jdbcType,
66+
jdbcType());
67+
configuration = configuration.toBuilder().setJdbcType(jdbcType()).build();
6468
}
6569

6670
List<@org.checkerframework.checker.nullness.qual.Nullable String> connectionInitSql =
6771
configuration.getConnectionInitSql();
6872
if (connectionInitSql != null && !connectionInitSql.isEmpty()) {
69-
LOG.warn("Postgres does not support connectionInitSql, ignoring.");
73+
throw new IllegalArgumentException("Postgres does not support connectionInitSql.");
7074
}
7175

7276
// Override "connectionInitSql" for postgres

sdks/python/apache_beam/transforms/external.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
ManagedTransforms.Urns.POSTGRES_WRITE.urn: _GCP_EXPANSION_SERVICE_JAR_TARGET, # pylint: disable=line-too-long
8686
ManagedTransforms.Urns.MYSQL_READ.urn: _GCP_EXPANSION_SERVICE_JAR_TARGET,
8787
ManagedTransforms.Urns.MYSQL_WRITE.urn: _GCP_EXPANSION_SERVICE_JAR_TARGET,
88+
ManagedTransforms.Urns.SQL_SERVER_READ.urn: _GCP_EXPANSION_SERVICE_JAR_TARGET, # pylint: disable=line-too-long
89+
ManagedTransforms.Urns.SQL_SERVER_WRITE.urn: _GCP_EXPANSION_SERVICE_JAR_TARGET, # pylint: disable=line-too-long
8890
}
8991

9092

0 commit comments

Comments
 (0)