apache/beam · error · IllegalArgumentException

SQL Server does not support connectionInitSql.

Error message

SQL Server does not support connectionInitSql.

What it means

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.

Source

Thrown at sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/ReadFromSqlServerSchemaTransformProvider.java:73

  }

  @Override
  public @UnknownKeyFor @NonNull @Initialized SchemaTransform from(
      JdbcReadSchemaTransformConfiguration 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("SQL Server does not support connectionInitSql.");
    }

    // Override "connectionInitSql" for sqlserver
    configuration = configuration.toBuilder().setConnectionInitSql(Collections.emptyList()).build();
    return new SqlServerReadSchemaTransform(configuration);
  }

  public static class SqlServerReadSchemaTransform extends JdbcReadSchemaTransform {
    public SqlServerReadSchemaTransform(JdbcReadSchemaTransformConfiguration config) {
      super(config, MSSQL);
      config.validate(MSSQL);
    }
  }
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Remove all connectionInitSql entries from the SQL Server read configuration
  2. Apply the needed session settings via SQL Server defaults (sp_configure, login/user defaults) or in the queries themselves
  3. Only populate connectionInitSql for database types that support it (e.g. MySQL)

Example fix

// before
builder().setConnectionInitSql(ImmutableList.of("SET ARITHABORT ON"))
// after
builder() // rely on server/database defaults instead of connectionInitSql
Defensive patterns

Strategy: validation

Validate before calling

if (connectionInitSql != null && !connectionInitSql.isEmpty()) {
  throw new IllegalArgumentException("SQL Server read does not support connectionInitSql; remove it from the config");
}

Prevention

When it happens

Trigger: Calling ReadFromSqlServerSchemaTransformProvider.from()/builder with a non-empty connectionInitSql list.

Common situations: 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.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/d4bc7c4e64cbfac9. Report an issue: GitHub.