prestodb/presto · error · ParquetDecodingException
not a valid mode
Error message
not a valid mode
What it means
Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder.readNext() decodes INT64 timestamp-micros dictionary indices, converting each dictionary value from microseconds to millis and packing it via packFunction before storing into the output array. The switch over the run's MODE throws ParquetDecodingException("not a valid mode " + mode) in the default branch when the run mode is unrecognized. This means the RLE hybrid header in the timestamp column's data page was invalid or the decoder state was corrupted, so the micros timestamp values cannot be decoded.
Source
Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder.java:88
final int rleValue = currentValue;
final long rleDictionaryValue = MICROSECONDS.toMillis(dictionary.decodeToLong(rleValue));
while (destinationIndex < endIndex) {
values[destinationIndex++] = packFunction.pack(rleDictionaryValue);
}
break;
}
case PACKED: {
final int[] localBuffer = currentBuffer;
final LongDictionary localDictionary = dictionary;
for (int srcIndex = currentBuffer.length - currentCount; destinationIndex < endIndex; srcIndex++) {
long dictionaryValue = localDictionary.decodeToLong(localBuffer[srcIndex]);
long millisValue = MICROSECONDS.toMillis(dictionaryValue);
values[destinationIndex++] = packFunction.pack(millisValue);
}
break;
}
default:
throw new ParquetDecodingException("not a valid mode " + mode);
}
currentCount -= numEntriesToFill;
remainingToCopy -= numEntriesToFill;
}
checkState(remainingToCopy == 0, "End of stream: Invalid read size request");
}
@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()) {View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the file with parquet-tools and re-export it if the timestamp column chunk is corrupt.
- Rewrite the data with standard Parquet writer settings (INT64 timestamp micros, standard RLE dictionary).
- Upgrade Presto — timestamp batch decoders have received correctness fixes across releases.
- Use the non-batch (streaming) timestamp reader path as a fallback for this file.
Example fix
// before
decoder.readNext(values, offset, length); // ParquetDecodingException: not a valid mode ...
// after
try {
decoder.readNext(values, offset, length);
} catch (ParquetDecodingException e) {
logger.warn(e, "Falling back to streaming reader for %s", path);
values = streamingReader.readTimestamps(offset, length);
} Defensive patterns
Strategy: fallback
Validate before calling
// Ensure the file passes footer validation before decoding timestamp pages
byte[] tail = readTail(dataSource, 8);
if (!endsWith(tail, "PAR1") && !endsWith(tail, "PARE")) {
throw new IOException("Invalid Parquet magic: " + dataSource.getId());
} Try / catch
try {
decoder.readNext(values, offset, length);
} catch (ParquetDecodingException e) {
logger.warn(e, "Timestamp batch decode failed for %s; using streaming reader", path);
values = streamingReader.readTimestamps(columnChunk, offset, length);
} Prevention
- Write timestamps with a standard logical type (TIMESTAMP_MICROS) instead of legacy INT96 where possible.
- Validate written files with parquet-tools before publishing.
- Upgrade Presto — timestamp batch decoders had parsing fixes.
- Keep a plain-encoding fallback path for known-problem files.
When it happens
Trigger: readNext() — reached via int64BatchReadWithSkipHelper — processes a run whose mode is not RLE/PACKED/dictionary-supported: malformed or truncated timestamp (MICROS unified) data page header, or misaligned page buffer.
Common situations: Corrupt timestamp column chunks in Parquet files; writers emitting non-standard isAdjustedToUTC/timestamp-micros pages; Presto version mismatch between batch reader expectations and file format; failed compaction jobs leaving partial files.
Related errors
- not a valid mode
- Still remaining to be read in current batch.
- Still remaining to be read in current batch.
- Corrupted Parquet file: extra %d values to be consumed when
- not a valid mode
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/c40ca5b14364ba0e.
Report an issue: GitHub.