{"record":{"id":"61c701f8cc93c368","repo":"apache/beam","slug":"postgres-does-not-support-connectioninitsql","errorCode":null,"errorMessage":"Postgres does not support connectionInitSql.","messagePattern":"Postgres does not support connectionInitSql\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/ReadFromPostgresSchemaTransformProvider.java","lineNumber":73,"sourceCode":"  }\n\n  @Override\n  public @UnknownKeyFor @NonNull @Initialized SchemaTransform from(\n      JdbcReadSchemaTransformConfiguration 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    Boolean disableAutoCommit = configuration.getDisableAutoCommit();\n    if (disableAutoCommit != null && !disableAutoCommit) {\n      LOG.warn(\"Postgres reads require disableAutoCommit to be true, overriding to true.\");\n    }\n\n    // Override \"connectionInitSql\" and \"disableAutoCommit\" for postgres\n    configuration =\n        configuration.toBuilder()\n            .setConnectionInitSql(Collections.emptyList())\n            .setDisableAutoCommit(true)\n            .build();\n    return new PostgresReadSchemaTransform(configuration);\n  }\n\n  public static class PostgresReadSchemaTransform extends JdbcReadSchemaTransform {\n    public PostgresReadSchemaTransform(JdbcReadSchemaTransformConfiguration config) {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/ReadFromPostgresSchemaTransformProvider.java#L55-L91","documentation":"Thrown by ReadFromPostgresSchemaTransformProvider.from() when a connectionInitSql list is supplied. The Postgres read path does not execute connection initialization SQL statements, so accepting the option silently would do nothing; the provider fails fast instead. The same provider also force-overrides disableAutoCommit to true because Postgres reads require it.","triggerScenarios":"Calling ReadFromPostgresSchemaTransformProvider.from()/builder with connectionInitSql set to a non-empty list of SQL statements.","commonSituations":"Reusing a shared JDBC connection configuration (originally written for MySQL or SQL Server where connectionInitSql is honored) for a Postgres read; templated pipeline configs that always populate connectionInitSql.","solutions":["Remove the connectionInitSql entries from the Postgres read configuration","If you need init SQL (e.g. SET TIME ZONE), run it outside Beam on the database/user defaults, or use a Postgres-compatible mechanism like ALTER ROLE ... SET","Move the read to a provider/dialect that supports connectionInitSql if the statements are mandatory"],"exampleFix":"// before\nbuilder().setConnectionInitSql(ImmutableList.of(\"SET search_path TO myschema\"))\n// after\nbuilder() // connectionInitSql not set; ensure search_path is the role/database default","handlingStrategy":"validation","validationCode":"if (connectionInitSql != null && !connectionInitSql.isEmpty()) {\n  throw new IllegalArgumentException(\"Postgres read does not support connectionInitSql; remove it from the config\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never share one JDBC config template across database dialects without pruning options","Apply session settings for Postgres via role/database defaults (ALTER ROLE ... SET)","Set disableAutoCommit=true explicitly for Postgres reads"],"tags":["jdbc","postgres","beam","configuration"],"backgroundTag":"unsupported-config-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}