{"record":{"id":"8adc610f129fd263","repo":"apache/seatunnel","slug":"failed-creating-table-s","errorCode":null,"errorMessage":"Failed creating table %s","messagePattern":"Failed creating table (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/psql/PostgresCatalog.java","lineNumber":191,"sourceCode":"            String createTableSql = postgresCreateTableSqlBuilder.build(tablePath);\n            executeInternal(dbUrl, createTableSql);\n\n            if (postgresCreateTableSqlBuilder.isHaveConstraintKey) {\n                String alterTableSql =\n                        \"ALTER TABLE \"\n                                + tablePath.getSchemaAndTableName(\"\\\"\")\n                                + \" REPLICA IDENTITY FULL;\";\n                executeInternal(dbUrl, alterTableSql);\n            }\n\n            if (CollectionUtils.isNotEmpty(postgresCreateTableSqlBuilder.getCreateIndexSqls())) {\n                for (String createIndexSql : postgresCreateTableSqlBuilder.getCreateIndexSqls()) {\n                    executeInternal(dbUrl, createIndexSql);\n                }\n            }\n\n        } catch (Exception ex) {\n            throw new CatalogException(\n                    String.format(\"Failed creating table %s\", tablePath.getFullName()), ex);\n        }\n    }\n\n    @Override\n    protected String getCreateTableSql(\n            TablePath tablePath, CatalogTable table, boolean createIndex) {\n        PostgresCreateTableSqlBuilder postgresCreateTableSqlBuilder =\n                new PostgresCreateTableSqlBuilder(table, createIndex);\n        return postgresCreateTableSqlBuilder.build(tablePath);\n    }\n\n    @Override\n    protected String getDropTableSql(TablePath tablePath) {\n        return \"DROP TABLE \\\"\"\n                + tablePath.getSchemaName()\n                + \"\\\".\\\"\"\n                + tablePath.getTableName()","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/psql/PostgresCatalog.java#L173-L209","documentation":"PostgresCatalog.createTableInternal wraps all failures of executing the generated CREATE TABLE (and any CREATE INDEX) statements into CatalogException(\"Failed creating table %s\"). The message names the target table; the actual SQL/connectivity error is the chained cause.","triggerScenarios":"createTable on PostgresCatalog reaching DDL execution when the CREATE TABLE SQL is rejected — e.g. type mapping producing an unsupported PG type, reserved identifiers, existing table, or index creation failure via postgresCreateTableSqlBuilder.getCreateIndexSqls().","commonSituations":"Unsupported source-to-Postgres type mappings, schema name not existing in the database, insufficient CREATE privilege, duplicate table, invalid index column configuration.","solutions":["Read the chained cause for the exact PostgreSQL error and failed statement","Verify the target schema exists and the user has CREATE privilege","Drop the pre-existing table or enable ignoreIfExists/drop-first","Fix unsupported column types in the SeaTunnel catalog schema before createTable"],"exampleFix":"// before\ncatalog.createTable(path, table, false); // CatalogException: Failed creating table\n// after\ntry {\n    catalog.createTable(path, table, false);\n} catch (CatalogException e) {\n    log.error(\"DDL failed for {}: {}\", path.getFullName(), e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"// pre-check privileges and existence\nboolean schemaExists = /* SELECT 1 FROM information_schema.schemata WHERE schema_name = ? */;\nboolean tableFree = !catalog.tableExists(tablePath);","typeGuard":null,"tryCatchPattern":"try { catalog.createTable(path, table, false); } catch (CatalogException e) { log.error(\"createTable {} failed: {}\", path.getFullName(), e.getCause()); }","preventionTips":["Verify PG column type mapping for all source types before DDL execution","Ensure target schema exists and user has CREATE privilege","Enable ignoreIfExists or drop existing tables to avoid duplicate-table DDL failures"],"tags":["jdbc","postgres","ddl","sql"],"backgroundTag":"database-write-failed","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"}