{"record":{"id":"39fdcc28fabeb73f","repo":"prestodb/presto","slug":"value-is-null-but-present-stream-is-missing-39fdcc","errorCode":null,"errorMessage":"Value is null but present stream is missing","messagePattern":"Value is null but present stream is missing","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java","lineNumber":134,"sourceCode":"\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 data reader\n                readOffset = presentStream.countBitsSet(readOffset);\n            }\n            if (readOffset > 0) {\n                if (dataStream == null) {\n                    throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), \"Value is not null but data stream is missing\");\n                }\n                dataStream.skip(readOffset);\n            }\n        }\n\n        Block block;\n        if (dataStream == 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 = RunLengthEncodedBlock.create(type, null, nextBatchSize);\n        }\n        else if (presentStream == null) {\n            block = readNonNullBlock();\n        }\n        else {\n            boolean[] isNull = new boolean[nextBatchSize];\n            int nullCount = presentStream.getUnsetBits(nextBatchSize, isNull);\n            if (nullCount == 0) {\n                block = readNonNullBlock();\n            }\n            else if (nullCount != nextBatchSize) {\n                block = readNullBlock(isNull, nextBatchSize - nullCount);\n            }\n            else {\n                block = RunLengthEncodedBlock.create(type, null, nextBatchSize);","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java#L116-L152","documentation":"If the DATA stream is null, all values in the batch must be null and the reader needs the PRESENT stream to know which rows are null. If presentStream is also null the layout is contradictory — the file claims a stream exists for a column that should be all-null — so readBlock throws OrcCorruptionException.","triggerScenarios":"readBlock where dataStream == null and presentStream == null while nextBatchSize > 0.","commonSituations":"Corrupt ORC files; writers incorrectly emitting neither DATA nor PRESENT streams; partial writes or storage-layer truncation.","solutions":["Verify/rewrite the corrupt files (orc-tools verify, Hive rewrite of the partition)","Restore affected partitions from backup","Fix/upgrade the producing writer so all-null columns include a PRESENT stream or correct row-group metadata","Upgrade Presto for more robust handling of all-null columns"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// orc-tools meta: confirm all-null columns still carry a PRESENT stream","typeGuard":null,"tryCatchPattern":"try { ... } catch (OrcCorruptionException e) { rewriteCorruptPartition(); }","preventionTips":["Verify files post-write with orc-tools","Ensure writers emit PRESENT streams for all-null columns","Restore corrupt partitions from backups","Upgrade Presto/writer for known all-null handling fixes"],"tags":["orc","corruption","null-handling","missing-stream"],"backgroundTag":"orc-corruption-missing-stream","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"}