{"record":{"id":"083ac24efb9c1d76","repo":"prestodb/presto","slug":"value-is-null-but-present-stream-is-missing","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/BooleanBatchStreamReader.java","lineNumber":120,"sourceCode":"                if (dataStream == null) {\n                    throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), \"Value is not null but data stream is not present\");\n                }\n                dataStream.skip(readOffset);\n            }\n        }\n\n        if (dataStream == null && presentStream != null) {\n            presentStream.skip(nextBatchSize);\n            Block nullValueBlock = RunLengthEncodedBlock.create(BOOLEAN, null, nextBatchSize);\n            readOffset = 0;\n            nextBatchSize = 0;\n            return nullValueBlock;\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(BOOLEAN, 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(BOOLEAN, null, nextBatchSize);","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/BooleanBatchStreamReader.java#L102-L138","documentation":"BooleanBatchStreamReader.readBlock throws OrcCorruptionException when every value in the batch is null (dataStream is null) yet the PRESENT stream is also missing. Per ORC spec, a column containing nulls must include a present stream to encode the null mask, so its absence makes null positions undeterminable.","triggerScenarios":"Reading a BOOLEAN column where dataStream == null (all values expected null) and presentStream == null during readBlock of the next batch.","commonSituations":"Malformed ORC files written without present streams despite null data; files produced by non-conformant or buggy writers; manual stream stripping/corruption during storage transfer.","solutions":["Regenerate the ORC file with a spec-compliant writer so null-carrying columns include present streams.","Validate with orc-tools and identify the non-conformant writer/version; upgrade it.","Check intermediate storage/compression layers for stream loss (e.g. partial uploads).","Catch OrcCorruptionException in the reader and skip/fail the split gracefully."],"exampleFix":"// before\nBlock b = streamReader.readBlock(); // throws\n// after\ntry { b = streamReader.readBlock(); } catch (OrcCorruptionException e) { b = RunLengthEncodedBlock.create(BOOLEAN, null, size); }","handlingStrategy":"try-catch","validationCode":"// confirm present streams exist for nullable columns\n// orc-tools meta file.orc | grep PRESENT","typeGuard":null,"tryCatchPattern":"try { block = streamReader.readBlock(); } catch (OrcCorruptionException e) { surfaceTableError(e); }","preventionTips":["Use spec-compliant ORC writers (Hive/Spark maintained versions)","Validate files with orc-tools before ingestion","Avoid custom stream manipulation of ORC files"],"tags":["orc","corruption","boolean","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"}