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

  1. Restore the original statistics resource file for the table from the Presto distribution
  2. Re-download/reinstall the Presto tpcds jar to fix a corrupt resource
  3. Check the cause exception for the exact JSON parse error location
  4. 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

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

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/a0fb90c13c6ef7c2. Report an issue: GitHub.