apache/seatunnel · error · TableAlreadyExistException

Table ${tablePath} already exists in catalog hive

Error message

Table ${tablePath} already exists in catalog hive

What it means

This error is raised by HiveMetaStoreCatalog.createTable when it attempts to create a table that already exists in the Hive Metastore and ignoreIfExists is false. It fires when a job or save-mode action tries to create a table whose metadata is already present in the target database; setting ignoreIfExists=true suppresses it, otherwise the caller must drop the table or pick a new name.

Source

Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java:634

            return convertHiveTableToCatalogTable(hiveTable);
        } catch (TableNotExistException e) {
            throw e;
        } catch (HiveConnectorException e) {
            throw new CatalogException("Failed to get table: " + tablePath, e);
        }
    }

    @Override
    public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreIfExists)
            throws TableAlreadyExistException, DatabaseNotExistException, CatalogException {
        try {
            if (!databaseExists(tablePath.getDatabaseName())) {
                throw new DatabaseNotExistException("hive", tablePath.getDatabaseName());
            }

            if (tableExists(tablePath.getDatabaseName(), tablePath.getTableName())) {
                if (!ignoreIfExists) {
                    throw new TableAlreadyExistException("hive", tablePath);
                }
                return;
            }

            Table hiveTable = convertCatalogTableToHiveTable(tablePath, table);
            createTableIfNotExists(hiveTable);
        } catch (TableAlreadyExistException | DatabaseNotExistException | CatalogException e) {
            throw e;
        } catch (HiveConnectorException e) {
            throw new CatalogException("Failed to create table: " + tablePath, e);
        } catch (TException e) {
            throw new CatalogException("Failed to create table: " + tablePath, e);
        }
    }

    @Override
    public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)
            throws TableNotExistException, CatalogException {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Pass ignoreIfExists=true if re-creating should be a no-op.
  2. Drop the existing table first (catalog.dropTable(tablePath, true)) if replacement is intended.
  3. Use a different table name or partition scheme for the new run.
  4. Guard with catalog.tableExists(tablePath) before creating.

Example fix

// before
catalog.createTable(tablePath, table, false); // fails on rerun
// after
catalog.createTable(tablePath, table, true); // idempotent
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = catalog.tableExists(tablePath);
catalog.createTable(tablePath, table, exists ? true : false); // or explicit policy

Try / catch

try {
    catalog.createTable(tablePath, table, false);
} catch (TableAlreadyExistException e) {
    // acceptable for idempotent re-runs; or drop and recreate deliberately
}

Prevention

When it happens

Trigger: Calling createTable(tablePath, table, false) for a table that already exists; re-running a job that creates tables without idempotency settings.

Common situations: Job restarts re-running DDL; concurrent pipelines writing the same table; forgetting to set ignoreIfExists=true for idempotent pipelines; leftover table from a previous failed run.

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/fe75fb6d3d8d5e01. Report an issue: GitHub.