{"record":{"id":"de6f721862e84666","repo":"prestodb/presto","slug":"value-is-null-but-present-stream-is-missing-de6f72","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/ByteBatchStreamReader.java","lineNumber":113,"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(TINYINT, 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(TINYINT, null, nextBatchSize);","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/ByteBatchStreamReader.java#L95-L131","documentation":"ByteBatchStreamReader.readBlock throws OrcCorruptionException when the byte data stream is absent (implying all-null values) but the PRESENT stream, required to encode which rows are null, is also missing. Without a present stream the reader cannot determine null positions, so the file is deemed corrupt.","triggerScenarios":"readBlock on a BYTE/TINYINT column where dataStream == null and presentStream == null for the upcoming batch.","commonSituations":"Non-conformant ORC writers omitting present streams on all-null columns; schema/type changes in the writer pipeline; corrupted footers causing stream misclassification.","solutions":["Rewrite the file with a spec-compliant ORC writer so present streams are emitted.","Validate the file with orc-tools and identify/upgrade the faulty writer.","Check whether a column type change made the reader expect a stream layout the writer never produced.","Catch OrcCorruptionException in the connector layer and route the split to an error handler."],"exampleFix":"// before: reading a non-conformant file\nBlock b = reader.readBlock(); // throws\n// after: re-encode the file\n// INSERT INTO fixed_table SELECT * FROM broken_table;  -- rewrites with present streams","handlingStrategy":"try-catch","validationCode":"// validate ORC file structure before query: orc-tools meta file.orc","typeGuard":null,"tryCatchPattern":"try { block = streamReader.readBlock(); } catch (OrcCorruptionException e) { logAndSkipSplit(e); }","preventionTips":["Regenerate files with maintained writer versions","Detect and avoid partial/stale files in table locations","Test writer output against an ORC validator in CI"],"tags":["orc","corruption","byte","present-stream","presto"],"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"}