apache/seatunnel · warning

table {} not exist when get the database catalog table

Error message

table {} not exist when get the database catalog table

What it means

getDatabaseTableSchema looks up the target table through the connector's catalog to fetch its schema and logs a WARN, returning Optional.empty(), when the catalog reports TableNotExistException. The writer then proceeds without DB-side schema info (e.g. auto-generated column handling), which can cause wrong column bindings downstream.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcSink.java:209

    private Optional<TableSchema> getDatabaseTableSchema() {
        Optional<Catalog> catalogOptional = getCatalog();
        FieldIdeEnum fieldIdeEnumEnum = config.get(JdbcSinkOptions.FIELD_IDE);
        String fieldIde =
                fieldIdeEnumEnum == null
                        ? FieldIdeEnum.ORIGINAL.getValue()
                        : fieldIdeEnumEnum.getValue();
        TablePath tablePath =
                TablePath.of(
                        catalogTable.getTableId().getDatabaseName(),
                        catalogTable.getTableId().getSchemaName(),
                        CatalogUtils.quoteTableIdentifier(
                                catalogTable.getTableId().getTableName(), fieldIde));
        if (catalogOptional.isPresent()) {
            try (Catalog catalog = catalogOptional.get()) {
                catalog.open();
                return Optional.of(catalog.getTable(tablePath).getTableSchema());
            } catch (TableNotExistException e) {
                log.warn("table {} not exist when get the database catalog table", tablePath);
                return Optional.empty();
            }
        }
        return Optional.empty();
    }

    @Override
    public Optional<SinkAggregatedCommitter<XidInfo, JdbcAggregatedCommitInfo>>
            createAggregatedCommitter() {
        // Load the JDBC driver in to DriverManager
        try {
            Class.forName(jdbcSinkConfig.getJdbcConnectionConfig().getDriverName());
        } catch (Exception e) {
            log.warn(
                    "Failed to load JDBC driver {}",
                    jdbcSinkConfig.getJdbcConnectionConfig().getDriverName(),
                    e);
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Create the sink table in the target database or enable the auto-create-table (schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST) option
  2. Fix database/table names in the sink config to match actual DB identifiers including case
  3. Verify the catalog URL points at the correct database instance/schema
  4. Check grants — some catalogs report missing tables when the user cannot see them

Example fix

// before
sink {
  Jdbc {
    database = "prod"
    table = "orders"
  }
}
// after: table actually exists or is created automatically
sink {
  Jdbc {
    schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"
    database = "prod"
    table = "orders"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

-- verify table exists before running the job
SELECT 1 FROM information_schema.tables
WHERE table_schema = 'prod' AND table_name = 'orders';

Try / catch

try {
    schema = catalog.getTable(tablePath).getTableSchema();
} catch (TableNotExistException e) {
    schema = createTableIfConfigured(tablePath); // schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST
}

Prevention

When it happens

Trigger: createWriter or restoreWriter asks for the sink table's schema while the table (database.table from TablePath) does not exist in the target database, or catalog resolves a different schema/database name than configured.

Common situations: Sink table never created and auto-create is disabled; typo in database/table name; case-sensitivity mismatch (Postgres lowercase vs config uppercase); wrong catalog configured so the lookup hits the wrong DB instance.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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