{"record":{"id":"ee0834a4465f7b9e","repo":"apache/beam","slug":"wrong-jdbc-type-expected-but-got-overriding-with-ee0834","errorCode":null,"errorMessage":"Wrong JDBC type. Expected '{}' but got '{}'. Overriding with '{}'.","messagePattern":"Wrong JDBC type\\. Expected '(.+?)' but got '(.+?)'\\. Overriding with '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/WriteToPostgresSchemaTransformProvider.java","lineNumber":62,"sourceCode":"    return getUrn(ExternalTransforms.ManagedTransforms.Urns.POSTGRES_WRITE);\n  }\n\n  @Override\n  public String description() {\n    return inheritedDescription(\"Postgres\", \"WriteToPostgres\", \"postgresql\", 5432);\n  }\n\n  @Override\n  protected String jdbcType() {\n    return POSTGRES;\n  }\n\n  @Override\n  public @UnknownKeyFor @NonNull @Initialized SchemaTransform from(\n      JdbcWriteSchemaTransformConfiguration configuration) {\n    String jdbcType = configuration.getJdbcType();\n    if (jdbcType != null && !jdbcType.isEmpty() && !jdbcType.equals(jdbcType())) {\n      LOG.warn(\n          \"Wrong JDBC type. Expected '{}' but got '{}'. Overriding with '{}'.\",\n          jdbcType(),\n          jdbcType,\n          jdbcType());\n      configuration = configuration.toBuilder().setJdbcType(jdbcType()).build();\n    }\n\n    List<@org.checkerframework.checker.nullness.qual.Nullable String> connectionInitSql =\n        configuration.getConnectionInitSql();\n    if (connectionInitSql != null && !connectionInitSql.isEmpty()) {\n      throw new IllegalArgumentException(\"Postgres does not support connectionInitSql.\");\n    }\n\n    // Override \"connectionInitSql\" for postgres\n    configuration = configuration.toBuilder().setConnectionInitSql(Collections.emptyList()).build();\n    return new PostgresWriteSchemaTransform(configuration);\n  }\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/WriteToPostgresSchemaTransformProvider.java#L44-L80","documentation":"Warning logged by the Postgres write SchemaTransform provider when the configuration's jdbcType does not match the provider's jdbcType(). The provider overrides the value with its own type and continues writing to Postgres. It signals a database mismatch in the write configuration.","triggerScenarios":"Passing a JdbcWriteSchemaTransformConfiguration with a non-empty jdbcType different from the Postgres provider's jdbcType() into WriteToPostgresSchemaTransformProvider.from().","commonSituations":"Sharing a write config builder between MySQL and Postgres sinks; programmatic pipeline generation using a hardcoded or stale jdbcType.","solutions":["Clear the jdbcType field so the Postgres default applies.","Set jdbcType to the Postgres provider's jdbcType() value.","Use the correct write provider for the intended database.","Verify the JDBC URL starts with jdbc:postgresql://."],"exampleFix":"// before\nJdbcWriteSchemaTransformConfiguration cfg = JdbcWriteSchemaTransformConfiguration.builder()\n    .setJdbcType(\"mysql\")\n    .setUrl(\"jdbc:postgresql://host/db\")\n    .build();\n// after\nJdbcWriteSchemaTransformConfiguration cfg = JdbcWriteSchemaTransformConfiguration.builder()\n    .setUrl(\"jdbc:postgresql://host/db\")\n    .build();","handlingStrategy":"validation","validationCode":"if (config.getJdbcType() != null && !config.getJdbcType().isEmpty()\n    && !\"postgres\".equalsIgnoreCase(config.getJdbcType())) {\n  throw new IllegalArgumentException(\"jdbcType must match the Postgres provider\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not set jdbcType for Postgres writes.","Use database-specific write providers rather than a shared config.","Check for stale jdbcType values when switching a pipeline's target database."],"tags":["jdbc","postgres","configuration","beam-io"],"backgroundTag":"invalid-config-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}