{"record":{"id":"50e178700c456941","repo":"prestodb/presto","slug":"value-is-not-null-but-length-stream-is-not-present","errorCode":null,"errorMessage":"Value is not null but length stream is not present","messagePattern":"Value is not null but length stream is not present","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/reader/SliceDirectBatchStreamReader.java","lineNumber":115,"sourceCode":"    }\n\n    @Override\n    public Block readBlock()\n            throws IOException\n    {\n        if (!rowGroupOpen) {\n            openRowGroup();\n        }\n\n        if (readOffset > 0) {\n            if (presentStream != null) {\n                // skip ahead the present bit reader, but count the set bits\n                // and use this as the skip size for the length reader\n                readOffset = presentStream.countBitsSet(readOffset);\n            }\n            if (readOffset > 0) {\n                if (lengthStream == null) {\n                    throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), \"Value is not null but length stream is not present\");\n                }\n                long dataSkipSize = lengthStream.sum(readOffset);\n                if (dataSkipSize > 0) {\n                    if (dataStream == null) {\n                        throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), \"Value is not null but data stream is not present\");\n                    }\n                    dataStream.skip(dataSkipSize);\n                }\n            }\n        }\n\n        if (lengthStream == null) {\n            if (presentStream == null) {\n                throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), \"Value is null but present stream is missing\");\n            }\n            presentStream.skip(nextBatchSize);\n            Block nullValueBlock = readAllNullsBlock();\n            readOffset = 0;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/SliceDirectBatchStreamReader.java#L97-L133","documentation":"While skipping over earlier non-null positions in a direct-encoded string column, the LENGTH stream must exist to know how many bytes to skip. Its absence while non-null values remain means the file's stream layout contradicts its metadata — flagged as ORC corruption.","triggerScenarios":"readBlock() with readOffset > 0, a presentStream marking non-null values, and lengthStream == null for the current row group.","commonSituations":"Truncated ORC files; non-conformant writers omitting LENGTH streams; corruption during copy or partial overwrite; reading files with mismatched stripe metadata.","solutions":["Validate the file with orc-tools to confirm the missing LENGTH stream.","Restore or regenerate the corrupt file.","Check for interrupted writes or partial uploads on the storage layer.","Verify the writer that produced the file is a supported, compliant version."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-flight: orc-tools meta file.orc  -> confirm LENGTH stream present for the direct-encoded string column","typeGuard":null,"tryCatchPattern":"try {\n    return reader.readBlock();\n} catch (OrcCorruptionException e) {\n    log.error(\"Missing LENGTH stream in %s\", e.getOrcDataSourceId());\n    throw new DataIntegrityException(\"ORC row group missing LENGTH stream\", e);\n}","preventionTips":["Verify checksums after copying ORC files between storage systems.","Reject files at ingest whose declared streams do not match their encoding.","Regenerate files from known-good writers."],"tags":["orc","corruption","missing-stream"],"backgroundTag":"orc-file-corruption","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"}