{"record":{"id":"2dbc59bb49a55d90","repo":"apache/seatunnel","slug":"unexpected-error-creating-table-dbname-table","errorCode":null,"errorMessage":"Unexpected error creating table: ${dbName}.${tableName}","messagePattern":"Unexpected error creating table: (.+?)\\.(.+?)","errorType":"exception","errorClass":"TException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java","lineNumber":491,"sourceCode":"\n    public void createTableIfNotExists(@NonNull Table tbl) throws TException {\n        try {\n            if (getClient().tableExists(tbl.getDbName(), tbl.getTableName())) {\n                log.debug(\"Table {}.{} already exists\", tbl.getDbName(), tbl.getTableName());\n                return;\n            }\n            log.info(\"Creating table {}.{}\", tbl.getDbName(), tbl.getTableName());\n            getClient().createTable(tbl);\n        } catch (org.apache.hadoop.hive.metastore.api.AlreadyExistsException e) {\n            log.debug(\"Table {}.{} already exists (race)\", tbl.getDbName(), tbl.getTableName());\n        } catch (TException e) {\n            String errorMsg =\n                    String.format(\n                            \"Failed to create table [%s.%s]\", tbl.getDbName(), tbl.getTableName());\n            throw new HiveConnectorException(\n                    HiveConnectorErrorCode.CREATE_HIVE_TABLE_FAILED, errorMsg, e);\n        } catch (Exception e) {\n            throw new TException(\n                    \"Unexpected error creating table: \"\n                            + tbl.getDbName()\n                            + \".\"\n                            + tbl.getTableName(),\n                    e);\n        }\n    }\n\n    public void addPartitions(\n            @NonNull String dbName, @NonNull String tableName, List<String> partitions)\n            throws TException {\n        for (String partition : partitions) {\n            try {\n                getClient().appendPartition(dbName, tableName, partition);\n            } catch (AlreadyExistsException ae) {\n                log.warn(\"Partition {} already exists\", partition);\n            }\n        }","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java#L473-L509","documentation":"A raw org.apache.hadoop.hive.metastore.api.TException thrown by createTableIfNotExists as a defensive catch-all for any unexpected non-Thrift Exception (RuntimeException etc.) during table creation. It signals an unexpected internal failure rather than a metastore-reported error.","triggerScenarios":"Any RuntimeException thrown inside createTableIfNotExists outside the handled TException/AlreadyExistsException branches — e.g. NPE building the Table object, invalid table metadata causing client-side failure.","commonSituations":"Programmatically constructed Table objects with null dbName/tableName or null storage descriptor; catalog client not initialized; bug in a custom client factory.","solutions":["Read the chained cause to find the actual runtime exception.","Validate the Table object (dbName, tableName, sd, columns) before calling createTableIfNotExists.","Ensure the catalog is open/initialized before use.","Capture the full stack trace and file a bug if it persists; this path is not an expected failure mode."],"exampleFix":"// before\n// catalog.createTableIfNotExists(tbl); // tbl.getDbName() was null\n\n// after\nObjects.requireNonNull(tbl.getDbName(), \"dbName required\");\nObjects.requireNonNull(tbl.getTableName(), \"tableName required\");\ncatalog.createTableIfNotExists(tbl);","handlingStrategy":"try-catch","validationCode":"Objects.requireNonNull(tbl.getDbName(), \"dbName\");\nObjects.requireNonNull(tbl.getTableName(), \"tableName\");\nObjects.requireNonNull(tbl.getSd(), \"storage descriptor\");","typeGuard":null,"tryCatchPattern":"try {\n    catalog.createTableIfNotExists(tbl);\n} catch (TException e) {\n    log.error(\"Unexpected table create failure for {}.{}: \", tbl.getDbName(), tbl.getTableName(), e.getCause());\n    throw e;\n}","preventionTips":["Fully populate Table metadata before creation","Ensure the catalog client is initialized","Treat this path as a bug signal: capture stack traces for reporting"],"tags":["hive","metastore","table","unexpected"],"backgroundTag":"internal-invariant-violation","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"}