prestodb/presto · error · OrcCorruptionException

Value is not null but length stream is not present

Error message

Value is not null but length stream is not present

What it means

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.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/SliceDirectBatchStreamReader.java:115

    }

    @Override
    public Block readBlock()
            throws IOException
    {
        if (!rowGroupOpen) {
            openRowGroup();
        }

        if (readOffset > 0) {
            if (presentStream != null) {
                // skip ahead the present bit reader, but count the set bits
                // and use this as the skip size for the length reader
                readOffset = presentStream.countBitsSet(readOffset);
            }
            if (readOffset > 0) {
                if (lengthStream == null) {
                    throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), "Value is not null but length stream is not present");
                }
                long dataSkipSize = lengthStream.sum(readOffset);
                if (dataSkipSize > 0) {
                    if (dataStream == null) {
                        throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), "Value is not null but data stream is not present");
                    }
                    dataStream.skip(dataSkipSize);
                }
            }
        }

        if (lengthStream == null) {
            if (presentStream == null) {
                throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), "Value is null but present stream is missing");
            }
            presentStream.skip(nextBatchSize);
            Block nullValueBlock = readAllNullsBlock();
            readOffset = 0;

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Validate the file with orc-tools to confirm the missing LENGTH stream.
  2. Restore or regenerate the corrupt file.
  3. Check for interrupted writes or partial uploads on the storage layer.
  4. Verify the writer that produced the file is a supported, compliant version.
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight: orc-tools meta file.orc  -> confirm LENGTH stream present for the direct-encoded string column

Try / catch

try {
    return reader.readBlock();
} catch (OrcCorruptionException e) {
    log.error("Missing LENGTH stream in %s", e.getOrcDataSourceId());
    throw new DataIntegrityException("ORC row group missing LENGTH stream", e);
}

Prevention

When it happens

Trigger: readBlock() with readOffset > 0, a presentStream marking non-null values, and lengthStream == null for the current row group.

Common situations: Truncated ORC files; non-conformant writers omitting LENGTH streams; corruption during copy or partial overwrite; reading files with mismatched stripe metadata.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/50e178700c456941. Report an issue: GitHub.