{"record":{"id":"67d04d58f5785f47","repo":"prestodb/presto","slug":"table-not-found-67d04d","errorCode":null,"errorMessage":"Table not found","messagePattern":"Table not found","errorType":"exception","errorClass":"TableNotFoundException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastore.java","lineNumber":1651,"sourceCode":"                                    privileges.addAll(parsePrivilege(hiveObjectPrivilege.getGrantInfo(), Optional.of(grantee)));\n                                }\n                                return privileges.build();\n                            })));\n        }\n        catch (TException e) {\n            throw new PrestoException(HIVE_METASTORE_ERROR, e);\n        }\n        catch (Exception e) {\n            throw propagate(e);\n        }\n    }\n\n    @Override\n    public MetastoreOperationResult dropConstraint(MetastoreContext metastoreContext, String databaseName, String tableName, String constraintName)\n    {\n        Optional<org.apache.hadoop.hive.metastore.api.Table> source = getTable(metastoreContext, databaseName, tableName);\n        if (!source.isPresent()) {\n            throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));\n        }\n\n        try {\n            retry()\n                    .stopOnIllegalExceptions()\n                    .run(\"dropConstraint\", stats.getDropConstraint().wrap(() ->\n                            getMetastoreClientThenCall(metastoreContext, client -> {\n                                client.dropConstraint(databaseName, tableName, constraintName);\n                                return null;\n                            })));\n            return EMPTY_RESULT;\n        }\n        catch (NoSuchObjectException e) {\n            throw new TableConstraintNotFoundException(Optional.of(constraintName));\n        }\n        catch (TException e) {\n            throw new PrestoException(HIVE_METASTORE_ERROR, e);\n        }","sourceCodeStart":1633,"sourceCodeEnd":1669,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastore.java#L1633-L1669","documentation":"dropConstraint in ThriftHiveMetastore first fetches the target table via getTable; if the metastore returns no such table it throws TableNotFoundException, reported to users as 'Table not found'. This is a pre-check so the caller gets a clear table-missing error instead of a raw metastore exception.","triggerScenarios":"Calling dropConstraint(metastoreContext, databaseName, tableName, constraintName) where databaseName/tableName do not exist in the Hive metastore (getTable returns Optional.empty()).","commonSituations":"Typo in table or schema name, table was dropped by another job/user, case-sensitivity mismatch (Hive stores lowercase names), pointing at a different metastore environment (staging vs prod) than expected.","solutions":["Verify the table exists: run SHOW TABLES IN <catalog>.<schema> or call metastore.getTable before dropping the constraint.","Correct the databaseName/tableName spelling and case (Hive names are lowercase).","Confirm you are connected to the intended metastore/catalog (environment mismatch is common).","Recreate the table if it was dropped concurrently, or skip the drop if the table no longer exists."],"exampleFix":"// before: unconditional drop\nmetastore.dropConstraint(context, db, table, constraintName);\n\n// after: check existence first\nif (metastore.getTable(context, db, table).isPresent()) {\n    metastore.dropConstraint(context, db, table, constraintName);\n}","handlingStrategy":"validation","validationCode":"Optional<Table> t = metastore.getTable(metastoreContext, db, table.toLowerCase(Locale.ROOT));\nif (t.isEmpty()) { throw new IllegalArgumentException(\"Table \" + db + \".\" + table + \" does not exist\"); }","typeGuard":null,"tryCatchPattern":"try {\n    metastore.dropConstraint(context, db, table, constraint);\n} catch (TableNotFoundException e) {\n    // table absent: log and skip\n}","preventionTips":["Always lowercase identifiers before metastore calls.","Check table existence before constraint DDL.","Confirm catalog/environment before mutating metadata.","Handle concurrent drops gracefully in shared environments."],"tags":["hive","metastore","table-not-found","ddl"],"backgroundTag":"table-not-found","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"}