{"record":{"id":"e7f674a7b65a5c87","repo":"apache/seatunnel","slug":"table-not-exist-when-get-the-database-catalog-t","errorCode":null,"errorMessage":"table {} not exist when get the database catalog table","messagePattern":"table (.+?) not exist when get the database catalog table","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcSink.java","lineNumber":209,"sourceCode":"    private Optional<TableSchema> getDatabaseTableSchema() {\n        Optional<Catalog> catalogOptional = getCatalog();\n        FieldIdeEnum fieldIdeEnumEnum = config.get(JdbcSinkOptions.FIELD_IDE);\n        String fieldIde =\n                fieldIdeEnumEnum == null\n                        ? FieldIdeEnum.ORIGINAL.getValue()\n                        : fieldIdeEnumEnum.getValue();\n        TablePath tablePath =\n                TablePath.of(\n                        catalogTable.getTableId().getDatabaseName(),\n                        catalogTable.getTableId().getSchemaName(),\n                        CatalogUtils.quoteTableIdentifier(\n                                catalogTable.getTableId().getTableName(), fieldIde));\n        if (catalogOptional.isPresent()) {\n            try (Catalog catalog = catalogOptional.get()) {\n                catalog.open();\n                return Optional.of(catalog.getTable(tablePath).getTableSchema());\n            } catch (TableNotExistException e) {\n                log.warn(\"table {} not exist when get the database catalog table\", tablePath);\n                return Optional.empty();\n            }\n        }\n        return Optional.empty();\n    }\n\n    @Override\n    public Optional<SinkAggregatedCommitter<XidInfo, JdbcAggregatedCommitInfo>>\n            createAggregatedCommitter() {\n        // Load the JDBC driver in to DriverManager\n        try {\n            Class.forName(jdbcSinkConfig.getJdbcConnectionConfig().getDriverName());\n        } catch (Exception e) {\n            log.warn(\n                    \"Failed to load JDBC driver {}\",\n                    jdbcSinkConfig.getJdbcConnectionConfig().getDriverName(),\n                    e);\n        }","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcSink.java#L191-L227","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create the sink table in the target database or enable the auto-create-table (schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST) option","Fix database/table names in the sink config to match actual DB identifiers including case","Verify the catalog URL points at the correct database instance/schema","Check grants — some catalogs report missing tables when the user cannot see them"],"exampleFix":"// before\nsink {\n  Jdbc {\n    database = \"prod\"\n    table = \"orders\"\n  }\n}\n// after: table actually exists or is created automatically\nsink {\n  Jdbc {\n    schema_save_mode = \"CREATE_SCHEMA_WHEN_NOT_EXIST\"\n    database = \"prod\"\n    table = \"orders\"\n  }\n}","handlingStrategy":"validation","validationCode":"-- verify table exists before running the job\nSELECT 1 FROM information_schema.tables\nWHERE table_schema = 'prod' AND table_name = 'orders';","typeGuard":null,"tryCatchPattern":"try {\n    schema = catalog.getTable(tablePath).getTableSchema();\n} catch (TableNotExistException e) {\n    schema = createTableIfConfigured(tablePath); // schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST\n}","preventionTips":["Enable schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST for sink tables","Match identifier case to the target DB (quote/uppercase for Postgres/Oracle, lowercase for Postgres defaults)","Validate database/table names against the live DB before job submission","Ensure the sink user has enough grants to see and read the table metadata"],"tags":["jdbc","catalog","table-not-exist","schema","sink"],"backgroundTag":"resource-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}