prestodb/presto · error · ParquetDecodingException
not a valid mode
Error message
not a valid mode
What it means
RepetitionLevelDecoder.readNext decodes repetition levels using either RLE or bit-packed mode, selected by the chunk header. A mode value outside the known enum means the repetition-level stream cannot be decoded and a ParquetDecodingException is thrown. This indicates malformed or unsupported repetition-level data in the column chunk.
Source
Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/RepetitionLevelDecoder.java:93
break;
}
case PACKED: {
final int[] localBuffer = currentBuffer;
do {
int rlValue = localBuffer[currentOffsetPackedBuffer];
currentOffsetPackedBuffer = currentOffsetPackedBuffer + 1;
repetitionLevels.add(rlValue);
if (rlValue == 0) {
remainingToCopy--;
}
remaining--;
}
while (currentOffsetPackedBuffer < endOffsetPackedBuffer && remainingToCopy > 0);
currentCount = endOffsetPackedBuffer - currentOffsetPackedBuffer;
break;
}
default:
throw new ParquetDecodingException("not a valid mode " + mode);
}
}
return batchSize - remainingToCopy;
}
@Override
public long getRetainedSizeInBytes()
{
return INSTANCE_SIZE + sizeOf(currentBuffer);
}
private boolean ensureBlockAvailable()
throws IOException
{
if (currentCount == 0) {
if (!decode()) {
return false;
}View on GitHub (pinned to 55bb57d202)
Solutions
- Validate the file with parquet-tools and check the repetition-level encoding on the affected column
- Re-write the file with a mainstream writer using standard RLE repetition levels
- Upgrade the Presto parquet reader to a version that handles the writer's encoding
- Confirm the file was not truncated in transfer (compare checksums) before filing a bug
Example fix
// before: reading a file whose nested column uses an unknown repetition-level mode
// after: rewrite the nested data with standard encodings
// df.repartition(1).write.format("parquet").save("/fixed/path") Defensive patterns
Strategy: validation
Validate before calling
// parquet-tools meta file.parquet | grep <nested column> # expect: RLE for repetition/definition levels
Try / catch
try {
pageReader.readNextPage();
} catch (ParquetDecodingException e) {
if (e.getMessage().contains("not a valid mode")) {
log.error("Corrupt repetition-level stream in " + column);
}
throw e;
} Prevention
- Check nested (list/map/struct) columns with parquet-tools before loading
- Reject files from unknown writers at ingest time
- Compare file checksums after any network transfer
- Keep the Presto parquet reader updated for new writer encodings
When it happens
Trigger: readNext() hits the default branch of its mode switch because the repetition-level chunk header encodes an unknown mode value (not RLE, not PACKED_BIT_PACKED).
Common situations: Corrupted or truncated nested-column (list/map/struct) Parquet files; files written by non-standard writers using unsupported repetition-level encodings; version mismatch between the writer and the Presto parquet reader.
Related errors
- Unsupported Parquet encoding:
- Failed to decode.
- We didn't read correct number of definitionLevels
- Still remaining to be read in current batch.
- Corrupted Parquet file: extra %d values to be consumed when
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/c3f2d6bd23c6f850.
Report an issue: GitHub.