apache/seatunnel · error · UnsupportedOperationException

Can't create JdbcDialect without compatible mode for…

Error message

Can't create JdbcDialect without compatible mode for Postgres

What it means

PostgresDialectFactory.create() without arguments is not supported for Postgres: the dialect requires a compatible mode to be selected. Callers must use the create(compatibleMode, fieldIde) overload instead; the no-arg version unconditionally throws UnsupportedOperationException.

Solutions

  1. Pass compatible_mode (e.g. 'postgres' or 'postgresLow') so create(compatibleMode, fieldIde) is invoked
  2. Ensure your dialect-resolution path forwards the connector's compatible_mode option instead of calling create()
  3. Use the URL-based factory resolution that supports Postgres parameters

Example fix

// before
JdbcDialect d = factory.create();
// after
JdbcDialect d = factory.create(compatibleMode, fieldIde); // compatibleMode from config
Defensive patterns

Strategy: type-guard

Validate before calling

if (compatibleMode == null) {
    throw new IllegalArgumentException("compatible_mode is required for postgres dialect");
}

Type guard

boolean canCreateNoArg = !(factory instanceof PostgresDialectFactory);

Try / catch

try { return factory.create(); } catch (UnsupportedOperationException e) { return factory.create(compatibleMode, fieldIde); }

Prevention

When it happens

Trigger: Invoking JdbcDialectFactory.create() (the no-arg overload) for the postgres dialect, e.g. via generic dialect resolution that ignores compatible mode.

Common situations: Framework code resolving a dialect by URL only ('jdbc:postgresql:...') without passing the compatible_mode config; custom tooling built on the factory API.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/5ebd8534c132a0d2. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresDialectFactory.java:43

import com.google.auto.service.AutoService;

import javax.annotation.Nonnull;

@AutoService(JdbcDialectFactory.class)
public class PostgresDialectFactory implements JdbcDialectFactory {
    @Override
    public String dialectFactoryName() {
        return DatabaseIdentifier.POSTGRESQL;
    }

    @Override
    public boolean acceptsURL(String url) {
        return url.startsWith("jdbc:postgresql:");
    }

    @Override
    public JdbcDialect create() {
        throw new UnsupportedOperationException(
                "Can't create JdbcDialect without compatible mode for Postgres");
    }

    @Override
    public JdbcDialect create(@Nonnull String compatibleMode, String fieldIde) {
        if ("postgresLow".equalsIgnoreCase(compatibleMode)) {
            return new PostgresLowDialect(fieldIde);
        }
        return new PostgresDialect(fieldIde);
    }
}

View on GitHub (pinned to cf67b549a7)