{"record":{"id":"748267f139232a2a","repo":"prestodb/presto","slug":"table-not-found-databasename-tablename","errorCode":null,"errorMessage":"Table not found: ${databaseName}.${tableName}","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/BridgingHiveMetastore.java","lineNumber":227,"sourceCode":"    @Override\n    public void dropTable(MetastoreContext metastoreContext, String databaseName, String tableName, boolean deleteData)\n    {\n        delegate.dropTable(metastoreContext, databaseName, tableName, deleteData);\n    }\n\n    @Override\n    public MetastoreOperationResult replaceTable(MetastoreContext metastoreContext, String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges)\n    {\n        checkArgument(!newTable.getTableType().equals(TEMPORARY_TABLE), \"temporary tables must never be stored in the metastore\");\n        return alterTable(metastoreContext, databaseName, tableName, toMetastoreApiTable(newTable, principalPrivileges, metastoreContext.getColumnConverter()));\n    }\n\n    @Override\n    public MetastoreOperationResult renameTable(MetastoreContext metastoreContext, String databaseName, String tableName, String newDatabaseName, String newTableName)\n    {\n        Optional<org.apache.hadoop.hive.metastore.api.Table> source = delegate.getTable(metastoreContext, databaseName, tableName);\n        if (!source.isPresent()) {\n            throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));\n        }\n        org.apache.hadoop.hive.metastore.api.Table table = source.get();\n        table.setDbName(newDatabaseName);\n        table.setTableName(newTableName);\n        return alterTable(metastoreContext, databaseName, tableName, table);\n    }\n\n    @Override\n    public MetastoreOperationResult addColumn(MetastoreContext metastoreContext, String databaseName, String tableName, String columnName, HiveType columnType, String columnComment)\n    {\n        Optional<org.apache.hadoop.hive.metastore.api.Table> source = delegate.getTable(metastoreContext, databaseName, tableName);\n        if (!source.isPresent()) {\n            throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));\n        }\n        org.apache.hadoop.hive.metastore.api.Table table = source.get();\n        Column column = new Column(columnName, columnType, Optional.ofNullable(columnComment), Optional.empty());\n        table.getSd().getCols().add(metastoreContext.getColumnConverter().fromColumn(column));\n        return alterTable(metastoreContext, databaseName, tableName, table);","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/BridgingHiveMetastore.java#L209-L245","documentation":"Thrown as TableNotFoundException when renameTable cannot find the source table in the metastore before attempting the rename. The Thrift delegate's getTable returned empty, so the operation aborts with the qualified name in the message.","triggerScenarios":"Calling renameTable / ALTER TABLE ... RENAME TO when databaseName.tableName does not exist in the Hive metastore, or the caller lacks permission to see it (metastore hides it).","commonSituations":"Typo in schema or table name; table was already renamed or dropped by another job; wrong catalog selected in the session; case-sensitivity mismatch; metastore connectivity pointed at a different HMS instance.","solutions":["Verify the table exists: SELECT * FROM system.metadata.tables WHERE schema_name='db' AND table_name='tbl' (or SHOW TABLES FROM db).","Check the session catalog points to the intended Hive metastore.","Fix typos and match exact case of schema/table names.","Confirm no concurrent job renamed or dropped the table; adjust your workflow."],"exampleFix":"// before\nALTER TABLE web.logs RENAME TO web.logsv2; -- logs does not exist\n// after\nSHOW TABLES FROM web; -- confirm exact name first\nALTER TABLE web.logs_v1 RENAME TO web.logs_v2;","handlingStrategy":"validation","validationCode":"// verify before ALTER TABLE ... RENAME\nSHOW TABLES FROM <database> LIKE '<tableName>';\n-- or\nSELECT * FROM system.metadata.tables\nWHERE table_schema = '<database>' AND table_name = '<tableName>';","typeGuard":null,"tryCatchPattern":"try {\n    metadata.renameTable(session, tableHandle, newTableName);\n} catch (TableNotFoundException e) {\n    LOG.error(\"Table %s missing in metastore: %s\", tableName, e.getMessage());\n}","preventionTips":["Always SHOW TABLES / SHOW CREATE TABLE before rename DDL","Use fully qualified catalog.schema.table names to avoid wrong-catalog mistakes","Check for concurrent rename/drop jobs in scheduling workflows","Watch for recently renamed tables in stale sessions and refresh metadata"],"tags":["hive","table-not-found","metastore","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"}