{"record":{"id":"714746f208094322","repo":"prestodb/presto","slug":"table-not-found-databasename-tablename-714746","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/ThriftHiveMetastore.java","lineNumber":494,"sourceCode":"                .map(FieldSchema::getName)\n                .collect(toImmutableList());\n        HiveBasicStatistics basicStatistics = getHiveBasicStatistics(table.getParameters());\n        Map<String, HiveColumnStatistics> columnStatistics = getTableColumnStatistics(metastoreContext, databaseName, tableName, dataColumns, basicStatistics.getRowCount());\n        return new PartitionStatistics(basicStatistics, columnStatistics);\n    }\n\n    private Map<String, HiveColumnStatistics> getTableColumnStatistics(MetastoreContext metastoreContext, String databaseName, String tableName, List<String> columns, OptionalLong rowCount)\n    {\n        try {\n            return retry()\n                    .stopOn(NoSuchObjectException.class, HiveViewNotSupportedException.class)\n                    .stopOnIllegalExceptions()\n                    .run(\"getTableColumnStatistics\", stats.getGetTableColumnStatistics().wrap(() ->\n                            getMetastoreClientThenCall(metastoreContext, client ->\n                                    groupStatisticsByColumn(client.getTableColumnStatistics(databaseName, tableName, columns), rowCount))));\n        }\n        catch (NoSuchObjectException e) {\n            throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));\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 Map<String, PartitionStatistics> getPartitionStatistics(MetastoreContext metastoreContext, String databaseName, String tableName, Set<String> partitionNames)\n    {\n        Table table = getTable(metastoreContext, databaseName, tableName)\n                .orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName)));\n        List<String> dataColumns = table.getSd().getCols().stream()\n                .map(FieldSchema::getName)\n                .collect(toImmutableList());\n        List<String> partitionColumns = table.getPartitionKeys().stream()","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftHiveMetastore.java#L476-L512","documentation":"TableNotFoundException is thrown by ThriftHiveMetastore.getTableColumnStatistics when the Hive Metastore reports NoSuchObjectException while fetching column statistics for databaseName.tableName. The table the query referenced does not exist in the metastore at statistics-fetch time.","triggerScenarios":"Calling getTableColumnStatistics (from columnStatistics during query planning) with a database/tableName for which client.getTableColumnStatistics raises NoSuchObjectException.","commonSituations":"Table dropped between query submission and planning; typo in table or schema name; querying a table that exists only in another catalog; stale metadata after metastore replication lag.","solutions":["Verify the table exists: SHOW TABLES FROM <schema> and check the exact name","Refresh/SHOW COLUMNS or re-run the query if the table was just recreated","Check you are connected to the correct catalog and metastore (dev vs prod)","Recreate the table or fix the DROP that removed it"],"exampleFix":"-- before\nSELECT * FROM hive.sales.salez;\n-- after (corrected table name)\nSELECT * FROM hive.sales.sales;","handlingStrategy":"validation","validationCode":"// Confirm the table exists before requesting column statistics\nboolean exists = metastore.getTable(databaseName, tableName).isPresent();\nif (!exists) {\n    throw new IllegalStateException(\"Table \" + databaseName + \".\" + tableName + \" does not exist in the metastore\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return columnStatistics(tableHandle, columns);\n}\ncatch (TableNotFoundException e) {\n    // table vanished mid-query; surface a clear message or fall back to empty stats\n    return Optional.empty();\n}","preventionTips":["Validate table existence (SHOW TABLES / information_schema.tables) before analysis jobs","Avoid dropping/recreating tables while queries referencing them are planning","Qualify names with the exact catalog and schema to avoid cross-catalog typos","Re-check names after metastore replication or migration activities"],"tags":["hive","metastore","table-not-found","statistics"],"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"}