{"record":{"id":"a0fb90c13c6ef7c2","repo":"prestodb/presto","slug":"failed-to-parse-stats-from-resource-s","errorCode":null,"errorMessage":"Failed to parse stats from resource [%s]","messagePattern":"Failed to parse stats from resource \\[(.+?)\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-tpcds/src/main/java/com/facebook/presto/tpcds/statistics/TableStatisticsDataRepository.java","lineNumber":90,"sourceCode":"    public Optional<TableStatisticsData> load(String schemaName, Table table)\n    {\n        schemaName = normalizeSchemaName(schemaName);\n        String filename = table.getName();\n        String resourcePath = \"/tpcds/statistics/\" + schemaName + \"/\" + filename + \".json\";\n        return readStatistics(resourcePath);\n    }\n\n    private Optional<TableStatisticsData> readStatistics(String resourcePath)\n    {\n        URL resource = getClass().getResource(resourcePath);\n        if (resource == null) {\n            return Optional.empty();\n        }\n        try {\n            return Optional.of(objectMapper.readValue(resource, TableStatisticsData.class));\n        }\n        catch (Exception e) {\n            throw new RuntimeException(format(\"Failed to parse stats from resource [%s]\", resourcePath), e);\n        }\n    }\n}\n","sourceCodeStart":72,"sourceCodeEnd":94,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-tpcds/src/main/java/com/facebook/presto/tpcds/statistics/TableStatisticsDataRepository.java#L72-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n// hand-edited stats file with trailing comma\n{\"columns\": [{\"name\": \"c\",}, ...]}\n// after\n// valid JSON restored from distribution\n{\"columns\": [{\"name\": \"c\", \"statistics\": {}}], ...}","handlingStrategy":"fallback","validationCode":"try (InputStream in = resource.openStream()) {\n    new ObjectMapper().readTree(in); // validate JSON parses before handing to repository\n}","typeGuard":null,"tryCatchPattern":"Optional<TableStatisticsData> stats;\ntry {\n    stats = repository.load(schemaName, table);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Failed to parse stats from resource\")) {\n        stats = Optional.empty(); // proceed without statistics\n    } else { throw e; }\n}","preventionTips":["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"],"tags":["statistics","json","parsing"],"backgroundTag":"stats-parse-failed","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"}