prestodb/presto · error · RuntimeException
Failed to parse stats from resource [%s]
Error message
Failed to parse stats from resource [%s]
What it means
TableStatisticsDataRepository.readStatistics deserializes a bundled statistics JSON resource into TableStatisticsData. Any parsing exception is wrapped in RuntimeException 'Failed to parse stats from resource [%s]'. It means a shipped or supplied statistics resource is corrupt or in an unexpected format.
Source
Thrown at presto-tpcds/src/main/java/com/facebook/presto/tpcds/statistics/TableStatisticsDataRepository.java:90
public Optional<TableStatisticsData> load(String schemaName, Table table)
{
schemaName = normalizeSchemaName(schemaName);
String filename = table.getName();
String resourcePath = "/tpcds/statistics/" + schemaName + "/" + filename + ".json";
return readStatistics(resourcePath);
}
private Optional<TableStatisticsData> readStatistics(String resourcePath)
{
URL resource = getClass().getResource(resourcePath);
if (resource == null) {
return Optional.empty();
}
try {
return Optional.of(objectMapper.readValue(resource, TableStatisticsData.class));
}
catch (Exception e) {
throw new RuntimeException(format("Failed to parse stats from resource [%s]", resourcePath), e);
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Restore the original statistics resource file for the table from the Presto distribution
- Re-download/reinstall the Presto tpcds jar to fix a corrupt resource
- Check the cause exception for the exact JSON parse error location
- If you supply custom stats files, validate them against TableStatisticsData's JSON schema
Example fix
// before
// hand-edited stats file with trailing comma
{"columns": [{"name": "c",}, ...]}
// after
// valid JSON restored from distribution
{"columns": [{"name": "c", "statistics": {}}], ...} Defensive patterns
Strategy: fallback
Validate before calling
try (InputStream in = resource.openStream()) {
new ObjectMapper().readTree(in); // validate JSON parses before handing to repository
} Try / catch
Optional<TableStatisticsData> stats;
try {
stats = repository.load(schemaName, table);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Failed to parse stats from resource")) {
stats = Optional.empty(); // proceed without statistics
} else { throw e; }
} Prevention
- Never hand-edit bundled statistics JSON resources
- Keep the presto-tpcds jar intact; verify checksums on install
- Validate custom stats files against TableStatisticsData structure before deployment
When it happens
Trigger: Calling load(schemaName, table) where the classpath/resource statistics file for that table exists but objectMapper.readValue fails — malformed JSON or JSON not matching TableStatisticsData's schema.
Common situations: Statistics resource truncated or hand-edited; resource format changed between Presto versions while an old cached/jar resource is on the classpath; packaging bug shipping an invalid JSON file.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse stats from resource [%s]
- INVALID_FUNCTION_ARGUMENT
- Invalid day-time interval:
- Invalid year-month interval:
- Response does not contain a JSON value
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/a0fb90c13c6ef7c2.
Report an issue: GitHub.