{"record":{"id":"d4bc7c4e64cbfac9","repo":"apache/beam","slug":"sql-server-does-not-support-connectioninitsql","errorCode":null,"errorMessage":"SQL Server does not support connectionInitSql.","messagePattern":"SQL Server 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/ReadFromSqlServerSchemaTransformProvider.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(\"SQL Server does not support connectionInitSql.\");\n    }\n\n    // Override \"connectionInitSql\" for sqlserver\n    configuration = configuration.toBuilder().setConnectionInitSql(Collections.emptyList()).build();\n    return new SqlServerReadSchemaTransform(configuration);\n  }\n\n  public static class SqlServerReadSchemaTransform extends JdbcReadSchemaTransform {\n    public SqlServerReadSchemaTransform(JdbcReadSchemaTransformConfiguration config) {\n      super(config, MSSQL);\n      config.validate(MSSQL);\n    }\n  }\n}\n","sourceCodeStart":55,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/ReadFromSqlServerSchemaTransformProvider.java#L55-L88","documentation":"Thrown by ReadFromSqlServerSchemaTransformProvider.from() when connectionInitSql is populated. The SQL Server read path does not support per-connection init SQL, so the provider rejects the configuration early; immediately afterwards it clears the list and builds a SqlServerReadSchemaTransform.","triggerScenarios":"Calling ReadFromSqlServerSchemaTransformProvider.from()/builder with a non-empty connectionInitSql list.","commonSituations":"Shared JDBC config objects reused across database types; templates that set connectionInitSql for MySQL compatibility; teams migrating a MySQL Beam pipeline to SQL Server without pruning options.","solutions":["Remove all connectionInitSql entries from the SQL Server read configuration","Apply the needed session settings via SQL Server defaults (sp_configure, login/user defaults) or in the queries themselves","Only populate connectionInitSql for database types that support it (e.g. MySQL)"],"exampleFix":"// before\nbuilder().setConnectionInitSql(ImmutableList.of(\"SET ARITHABORT ON\"))\n// after\nbuilder() // rely on server/database defaults instead of connectionInitSql","handlingStrategy":"validation","validationCode":"if (connectionInitSql != null && !connectionInitSql.isEmpty()) {\n  throw new IllegalArgumentException(\"SQL Server read does not support connectionInitSql; remove it from the config\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep dialect-specific config builders (mysql/postgres/sqlserver) instead of a shared one","Use SQL Server database/user defaults for session settings","Lint pipeline configs for unsupported options before deployment"],"tags":["jdbc","sqlserver","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"}