apache/seatunnel · error · TableAlreadyExistException

TableAlreadyExistException: catalogName, tablePath

Error message

TableAlreadyExistException: catalogName, tablePath

What it means

createTable() throws the standard SeaTunnel TableAlreadyExistException when the target table already exists in Databend and ignoreIfExists is false. This is a pre-check the catalog performs before issuing CREATE TABLE.

Source

Thrown at seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/catalog/DatabendCatalog.java:305

    }

    @Override
    public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreIfExists)
            throws TableAlreadyExistException, DatabaseNotExistException, CatalogException {
        checkOpen();

        String databaseName = tablePath.getDatabaseName();
        String tableName = tablePath.getTableName();

        if (!databaseExists(databaseName)) {
            throw new DatabaseNotExistException(catalogName, databaseName);
        }

        if (tableExists(tablePath)) {
            if (ignoreIfExists) {
                return;
            }
            throw new TableAlreadyExistException(catalogName, tablePath);
        }

        String createTableSql =
                buildCreateTableSql(databaseName, tableName, table.getTableSchema());

        try (Connection connection = getConnection();
                Statement statement = connection.createStatement()) {
            statement.execute(createTableSql);
        } catch (SQLException e) {
            throw new DatabendConnectorException(
                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,
                    "Failed to create table: " + e.getMessage(),
                    e);
        }
    }

    @Override
    public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Pass ignoreIfExists=true if re-running should skip existing tables.
  2. Drop the existing table first (catalog.dropTable(tablePath, false)) if it should be recreated.
  3. Use a different table name/ TablePath for the new run.

Example fix

// before
catalog.createTable(tablePath, table, false); // throws on re-run
// after
catalog.createTable(tablePath, table, true); // idempotent re-run
Defensive patterns

Strategy: validation

Validate before calling

if (catalog.tableExists(tablePath)) { /* skip or drop first */ } else { catalog.createTable(tablePath, table, false); }

Try / catch

try { catalog.createTable(tablePath, table, false); } catch (TableAlreadyExistException e) { log.warn("Table {} already exists, skipping", tablePath); }

Prevention

When it happens

Trigger: Calling createTable(tablePath, table, false) when tableExists(tablePath) is true — the table was already created by a previous run or another process.

Common situations: Re-running a batch job without cleanup; concurrent jobs creating the same table; intentionally idempotent runs that forgot to pass ignoreIfExists=true.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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