prestodb/presto · error · ParquetDecodingException
not a valid mode
Error message
not a valid mode
What it means
Int32RLEDictionaryValuesDecoder.readNext() fills value batches by switching on the decoder's MODE (RLE_RUN, PACKED, or dictionary-index run). The default branch throws ParquetDecodingException("not a valid mode " + mode) when the current mode enum is unrecognized. Because the mode is set internally from the RLE header's low bit, this fires when the header stream yields an unexpected mode or decoder state was never initialized to a supported mode, indicating malformed or unsupported page data for an INT32 dictionary-encoded column.
Source
Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int32RLEDictionaryValuesDecoder.java:76
case RLE: {
final int rleValue = currentValue;
final int rleDictionaryValue = dictionary.decodeToInt(rleValue);
while (destinationIndex < endIndex) {
values[destinationIndex++] = rleDictionaryValue;
}
break;
}
case PACKED: {
final int[] localCurrentBuffer = currentBuffer;
final IntegerDictionary localDictionary = dictionary;
for (int sourceIndex = currentBuffer.length - currentCount; destinationIndex < endIndex; sourceIndex++) {
int dictionaryValue = localDictionary.decodeToInt(localCurrentBuffer[sourceIndex]);
values[destinationIndex++] = dictionaryValue;
}
break;
}
default:
throw new ParquetDecodingException("not a valid mode " + mode);
}
currentCount -= numEntriesToFill;
remainingToCopy -= numEntriesToFill;
}
}
@Override
public void skip(int length)
throws IOException
{
checkArgument(length >= 0, "invalid length %s", length);
int remaining = length;
while (remaining > 0) {
if (currentCount == 0) {
if (!decode()) {
break;
}View on GitHub (pinned to 55bb57d202)
Solutions
- Validate the file with parquet-tools and re-export it if the page data is corrupt or truncated.
- Disable dictionary encoding for the column on the writer side (e.g., parquet.enable.dictionary=false) and rewrite the file as plain/RLE.
- Confirm the reader and writer versions agree on the Parquet format; upgrade Presto to pick up batch-reader fixes.
- Fall back to the non-batch Parquet reader path for this column, which handles more edge cases.
Example fix
// before
Int32RLEDictionaryValuesDecoder d = new Int32RLEDictionaryValuesDecoder(...);
d.readNext(buffer, 100); // ParquetDecodingException: not a valid mode ...
// after: guard the read and fall back
try {
d.readNext(buffer, 100);
} catch (ParquetDecodingException e) {
values = readWithStreamingReader(columnChunk, 100); // non-batch fallback
} Defensive patterns
Strategy: fallback
Validate before calling
// Check the column chunk encoding before using the dictionary batch decoder
Encoding enc = chunk.getEncoding();
if (enc != Encoding.RLE_DICTIONARY && enc != Encoding.PLAIN_DICTIONARY) {
throw new IllegalStateException("Unexpected encoding " + enc + " for " + column);
} Try / catch
try {
decoder.readNext(buffer, length);
} catch (ParquetDecodingException e) {
values = streamingReader.readInts(columnChunk, length); // non-batch fallback
} Prevention
- Disable dictionary encoding on the writer for columns with malformed-page history.
- Validate files post-write with parquet-tools dump.
- Upgrade Presto to a release with batch-reader RLE fixes.
- Alert on job failures that may leave truncated files in table locations.
When it happens
Trigger: Public readNext() (batch read path) processes a run whose mode field holds a value not covered by the switch — i.e., the RLE/bit-packed hybrid header decoded from the page buffer produced an out-of-enum mode, typically from a malformed or truncated data page for an INT32 dictionary-encoded column.
Common situations: Corrupt or truncated Parquet INT32 column chunks; files written by writers emitting non-standard RLE headers; page-byte-offset miscomputation after dictionary-page decoding; Presto batch-reader bugs with certain hybrid RLE runs in older releases.
Related errors
- not a valid mode
- not a valid mode
- not a valid mode
- could not decode the dictionary for
- Unsupported Parquet encoding:
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/5e1715043c69f009.
Report an issue: GitHub.