apache/beam · warning
Wrong JDBC type. Expected '{}' but got '{}'. Overriding with
Error message
Wrong JDBC type. Expected '{}' but got '{}'. Overriding with '{}'. What it means
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.
Source
Thrown at sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/WriteToPostgresSchemaTransformProvider.java:62
return getUrn(ExternalTransforms.ManagedTransforms.Urns.POSTGRES_WRITE);
}
@Override
public String description() {
return inheritedDescription("Postgres", "WriteToPostgres", "postgresql", 5432);
}
@Override
protected String jdbcType() {
return POSTGRES;
}
@Override
public @UnknownKeyFor @NonNull @Initialized SchemaTransform from(
JdbcWriteSchemaTransformConfiguration configuration) {
String jdbcType = configuration.getJdbcType();
if (jdbcType != null && !jdbcType.isEmpty() && !jdbcType.equals(jdbcType())) {
LOG.warn(
"Wrong JDBC type. Expected '{}' but got '{}'. Overriding with '{}'.",
jdbcType(),
jdbcType,
jdbcType());
configuration = configuration.toBuilder().setJdbcType(jdbcType()).build();
}
List<@org.checkerframework.checker.nullness.qual.Nullable String> connectionInitSql =
configuration.getConnectionInitSql();
if (connectionInitSql != null && !connectionInitSql.isEmpty()) {
throw new IllegalArgumentException("Postgres does not support connectionInitSql.");
}
// Override "connectionInitSql" for postgres
configuration = configuration.toBuilder().setConnectionInitSql(Collections.emptyList()).build();
return new PostgresWriteSchemaTransform(configuration);
}
View on GitHub (pinned to 12126d8942)
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://.
Example fix
// before
JdbcWriteSchemaTransformConfiguration cfg = JdbcWriteSchemaTransformConfiguration.builder()
.setJdbcType("mysql")
.setUrl("jdbc:postgresql://host/db")
.build();
// after
JdbcWriteSchemaTransformConfiguration cfg = JdbcWriteSchemaTransformConfiguration.builder()
.setUrl("jdbc:postgresql://host/db")
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (config.getJdbcType() != null && !config.getJdbcType().isEmpty()
&& !"postgres".equalsIgnoreCase(config.getJdbcType())) {
throw new IllegalArgumentException("jdbcType must match the Postgres provider");
} Prevention
- 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.
When it happens
Trigger: Passing a JdbcWriteSchemaTransformConfiguration with a non-empty jdbcType different from the Postgres provider's jdbcType() into WriteToPostgresSchemaTransformProvider.from().
Common situations: Sharing a write config builder between MySQL and Postgres sinks; programmatic pipeline generation using a hardcoded or stale jdbcType.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Wrong JDBC type. Expected '{}' but got '{}'. Overriding with
- Postgres reads require disableAutoCommit to be true, overrid
- Postgres does not support connectionInitSql.
- Postgres does not support connectionInitSql.
- Wrong JDBC type. Expected '{}' but got '{}'. Overriding with
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/ee0834a4465f7b9e.
Report an issue: GitHub.