{"record":{"id":"79a91154816c8e9d","repo":"prestodb/presto","slug":"errordetail-errormessage","errorCode":null,"errorMessage":"errorDetail.errorMessage()","messagePattern":"errorDetail\\.errorMessage\\(\\)","errorType":"exception","errorClass":"TableNotFoundException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/GlueHiveMetastore.java","lineNumber":1276,"sourceCode":"    }\n\n    private static void propagateBatchUpdatePartitionErrorToPrestoException(String databaseName, String tableName, List<BatchUpdatePartitionFailureEntry> failureEntries)\n    {\n        if (failureEntries != null && !failureEntries.isEmpty()) {\n            ErrorDetail errorDetail = failureEntries.get(0).errorDetail();\n            propagateErrorDetailToPrestoException(databaseName, tableName, errorDetail);\n        }\n    }\n\n    private static void propagateErrorDetailToPrestoException(String databaseName, String tableName, ErrorDetail errorDetail)\n    {\n        String glueExceptionCode = errorDetail.errorCode();\n\n        switch (glueExceptionCode) {\n            case \"AlreadyExistsException\":\n                throw new PrestoException(ALREADY_EXISTS, errorDetail.errorMessage());\n            case \"EntityNotFoundException\":\n                throw new TableNotFoundException(new SchemaTableName(databaseName, tableName), errorDetail.errorMessage());\n            default:\n                throw new PrestoException(HIVE_METASTORE_ERROR, errorDetail.errorCode() + \": \" + errorDetail.errorMessage());\n        }\n    }\n\n    @Override\n    public void dropPartition(MetastoreContext metastoreContext, String databaseName, String tableName, List<String> parts, boolean deleteData)\n    {\n        Table table = getTableOrElseThrow(metastoreContext, databaseName, tableName);\n        Partition partition = getPartition(metastoreContext, databaseName, tableName, parts)\n                .orElseThrow(() -> new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), parts));\n\n        try {\n            awsSyncRequest(\n                    glueClient::deletePartition,\n                    DeletePartitionRequest.builder()\n                            .catalogId(catalogId)\n                            .databaseName(databaseName)","sourceCodeStart":1258,"sourceCodeEnd":1294,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/GlueHiveMetastore.java#L1258-L1294","documentation":"GlueHiveMetastore translates AWS Glue catalog exceptions into Presto exceptions. When Glue reports AlreadyExistsException the metastore throws PrestoException(ALREADY_EXISTS); when it reports EntityNotFoundException it throws TableNotFoundException. The message is the raw errorMessage() string returned by AWS Glue.","triggerScenarios":"Calling any GlueHiveMetastore method (createDatabase, createTable, etc.) via invokeGlueClient when the Glue API returns an error detail with errorCode AlreadyExistsException or EntityNotFoundException. Note EntityNotFoundException maps to TableNotFoundException regardless of whether the missing entity is actually a table.","commonSituations":"Creating a database or table that already exists in the Glue catalog; concurrent CREATE TABLE race; CREATE TABLE ... IF NOT EXISTS handled without checking first; a database rename or stale cache leaving the catalog inconsistent.","solutions":["Check existence first: call getDatabase/getTable and handle AlreadyExists semantics in the caller before issuing the create","If using CREATE TABLE/IF NOT EXISTS, catch PrestoException with code ALREADY_EXISTS and treat it as success if the existing definition is compatible","For EntityNotFoundException, verify the database and table names (case sensitivity, quotes) against the Glue catalog before retrying","Inspect errorMessage() contents; Glue may report a missing table vs database and the message includes the entity name"],"exampleFix":"// before\nmetastore.createDatabase(new Database(name, ...));\n// after\nif (metastore.getDatabase(name).isEmpty()) {\n    metastore.createDatabase(new Database(name, ...));\n}","handlingStrategy":"try-catch","validationCode":"Optional<Database> db = metastore.getDatabase(name, metastoreContext);\nif (db.isPresent()) { /* skip create or reconcile */ }","typeGuard":null,"tryCatchPattern":"try {\n    metastore.createDatabase(db);\n} catch (PrestoException e) {\n    if (e.getErrorCode().equals(StandardErrorCode.ALREADY_EXISTS.toErrorCode())) {\n        // treat as success or verify existing entity\n    } else {\n        throw e;\n    }\n}","preventionTips":["Check existence before create operations","Handle idempotent creation explicitly instead of relying on errors","Watch for EntityNotFoundException from Glue meaning database missing, not only table"],"tags":["glue","metastore","presto-exception"],"backgroundTag":"glue-already-exists","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}