{"record":{"id":"4708e4c0efdb7643","repo":"prestodb/presto","slug":"failed-to-decode","errorCode":null,"errorMessage":"Failed to decode.","messagePattern":"Failed to decode\\.","errorType":"exception","errorClass":"ParquetDecodingException","httpStatus":null,"severity":"error","filePath":"presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/AbstractNestedBatchReader.java","lineNumber":121,"sourceCode":"        readOffset = readOffset + nextBatchSize;\n        nextBatchSize = batchSize;\n    }\n\n    @Override\n    public ColumnChunk readNext(Optional<DateTimeZone> timezone)\n    {\n        ColumnChunk columnChunk = null;\n        try {\n            seek();\n            if (field.isRequired()) {\n                columnChunk = readNestedNoNull(timezone);\n            }\n            else {\n                columnChunk = readNestedWithNull(timezone);\n            }\n        }\n        catch (IOException ex) {\n            throw new ParquetDecodingException(\"Failed to decode.\", ex);\n        }\n\n        readOffset = 0;\n        nextBatchSize = 0;\n        return columnChunk;\n    }\n\n    @Override\n    public long getRetainedSizeInBytes()\n    {\n        return INSTANCE_SIZE +\n                (pageReader == null ? 0 : pageReader.getRetainedSizeInBytes()) +\n                (dictionary == null ? 0 : dictionary.getRetainedSizeInBytes()) +\n                (repetitionLevelDecoder == null ? 0 : repetitionLevelDecoder.getRetainedSizeInBytes()) +\n                (definitionLevelDecoder == null ? 0 : definitionLevelDecoder.getRetainedSizeInBytes()) +\n                (valuesDecoder == null ? 0 : valuesDecoder.getRetainedSizeInBytes());\n    }\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/AbstractNestedBatchReader.java#L103-L139","documentation":"AbstractNestedBatchReader.readNext wraps any IOException raised while reading or decoding a nested (ARRAY/MAP/STRUCT) column chunk into a bare ParquetDecodingException with the message 'Failed to decode.' and the IOException as cause. Because it is generic, the real root cause (truncated file, checksum failure, corrupt page, network/IO error) is in the chained exception. It indicates the column chunk could not be decoded at all, not that values were wrong.","triggerScenarios":"readNext() on a nested batch reader when the underlying readNested/readNestedWithNull path throws IOException — e.g. failed page read, corrupt dictionary page, or input stream error.","commonSituations":"Truncated or corrupt Parquet files (failed write, bad copy/S3 multipart issues); HDFS/S3 transient IO errors mid-scan; files written by incompatible writer versions with malformed pages.","solutions":["Inspect the caused-by IOException chain for the true root cause (EOF, checksum, connection reset, etc.) and act on it.","Re-read/refresh the file: if it is truncated or corrupted, restore it from the source or re-run the writing job.","Retry the query if the cause was a transient storage (S3/HDFS) error.","Validate the file with a Parquet metadata tool (parquet-tools) to confirm structural corruption before debugging the reader."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight: read the file footer to catch truncation early\nParquetMetadata footer = ParquetFileReader.readFooter(configuration, new Path(path));\nlong fileLen = fileSystem.getFileStatus(new Path(path)).getLen();\nif (fileLen < footer.getBlocks().get(footer.getBlocks().size()-1).getEndingPos()) {\n    throw new IllegalStateException(\"File truncated: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return readNext(timezone);\n} catch (ParquetDecodingException e) {\n    Throwable root = e.getCause();\n    if (root instanceof IOException && isTransientStorageError((IOException) root)) {\n        return retryReadWithBackoff();\n    }\n    throw e;\n}","preventionTips":["Monitor storage for transient IO errors; configure client retries for S3/HDFS.","Verify file completeness (checksums) after writes and copies.","Capture the cause chain — the 'Failed to decode.' message alone is not diagnosable."],"tags":["parquet","io","decoding","nested-columns"],"backgroundTag":"corrupt-parquet-file","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"}