shunping commented on code in PR #36034:
URL: https://github.com/apache/beam/pull/36034#discussion_r2323808253


##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/WriteToPostgresSchemaTransformProvider.java:
##########
@@ -43,4 +53,31 @@ public String description() {
   protected String jdbcType() {
     return POSTGRES;
   }
+
+  @Override
+  public @UnknownKeyFor @NonNull @Initialized SchemaTransform from(
+      JdbcWriteSchemaTransformConfiguration configuration) {
+    String jdbcType = configuration.getJdbcType();
+    if (jdbcType != null && !jdbcType.equals(jdbcType())) {
+      throw new IllegalArgumentException(
+          String.format("Wrong JDBC type. Expected '%s' but got '%s'", 
jdbcType(), jdbcType));
+    }
+
+    List<@org.checkerframework.checker.nullness.qual.Nullable String> 
connectionInitSql =
+        configuration.getConnectionInitSql();
+    if (connectionInitSql != null && !connectionInitSql.isEmpty()) {
+      LOG.warn("Postgres does not support connectionInitSql, ignoring.");
+    }
+
+    // Override "connectionInitSql" for postgres
+    configuration = 
configuration.toBuilder().setConnectionInitSql(Collections.emptyList()).build();
+    return new PostgresWriteSchemaTransform(configuration);
+  }
+
+  public static class PostgresWriteSchemaTransform extends 
JdbcWriteSchemaTransform {
+    public PostgresWriteSchemaTransform(JdbcWriteSchemaTransformConfiguration 
config) {
+      super(config, POSTGRES);
+      config.validate(POSTGRES);

Review Comment:
   Same as ReadFromPostgresSchemaTransformProvider. Will remove this validation 
call.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to