{"record":{"id":"b4806999c1d1b14e","repo":"prestodb/presto","slug":"not-a-valid-mode-b48069","errorCode":null,"errorMessage":"not a valid mode ","messagePattern":"not a valid mode ","errorType":"exception","errorClass":"ParquetDecodingException","httpStatus":null,"severity":"error","filePath":"presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int64RLEDictionaryValuesDecoder.java","lineNumber":77,"sourceCode":"                case RLE: {\n                    final int rleValue = currentValue;\n                    final long rleDictionaryValue = dictionary.decodeToLong(rleValue);\n                    while (destinationIndex < endIndex) {\n                        values[destinationIndex++] = rleDictionaryValue;\n                    }\n                    break;\n                }\n                case PACKED: {\n                    final int[] localBuffer = currentBuffer;\n                    final LongDictionary localDictionary = dictionary;\n                    for (int srcIndex = currentBuffer.length - currentCount; destinationIndex < endIndex; srcIndex++) {\n                        long dictionaryValue = localDictionary.decodeToLong(localBuffer[srcIndex]);\n                        values[destinationIndex++] = dictionaryValue;\n                    }\n                    break;\n                }\n                default:\n                    throw new ParquetDecodingException(\"not a valid mode \" + mode);\n            }\n\n            currentCount -= numEntriesToFill;\n            remainingToCopy -= numEntriesToFill;\n        }\n\n        checkState(remainingToCopy == 0, \"End of stream: Invalid read size request\");\n    }\n\n    @Override\n    public void skip(int length)\n            throws IOException\n    {\n        checkArgument(length >= 0, \"invalid length %s\", length);\n        int remaining = length;\n        while (remaining > 0) {\n            if (currentCount == 0) {\n                if (!decode()) {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int64RLEDictionaryValuesDecoder.java#L59-L95","documentation":"Int64RLEDictionaryValuesDecoder.readNext() fills batches of INT64 values from an RLE/bit-packed run whose mode (RLE run, packed bit-packed run, or dictionary index run) is selected by a switch. The default branch throws ParquetDecodingException(\"not a valid mode \" + mode) when the run's mode is not one of the supported enum values. This indicates the header decoded from the page buffer is invalid or the decoder was driven with data that does not match the Parquet RLE hybrid encoding spec for INT64 dictionary-encoded columns.","triggerScenarios":"Public readNext() (batch read path) encounters a run whose decoded mode is outside the supported set — caused by a malformed/truncated INT64 data page header, byte misalignment in the page buffer, or uninitialized decoder mode being read.","commonSituations":"Corrupt or partially written Parquet files (e.g., failed job left truncated column chunks); non-conformant third-party Parquet writers; wrong page-offset metadata; older Presto versions with batch-reader RLE bugs on INT64 columns.","solutions":["Run parquet-tools dump/meta on the file; if corrupt, regenerate the file from the source data.","Rewrite the column without dictionary encoding (parquet.enable.dictionary=false) to use plain encoding.","Upgrade Presto to the latest patch release — batch RLE decoders have had header-parsing fixes.","Route the query to the non-batch reader fallback or disable the batch reader for this file."],"exampleFix":"// before\nInt64RLEDictionaryValuesDecoder d = new Int64RLEDictionaryValuesDecoder(...);\nd.readNext(values, offset, length); // throws 'not a valid mode ...'\n\n// after: validate file first, then decode\nParquetMetadata meta = MetadataReader.readFooter(dataSource, size); // surfaces corruption early\ntry {\n    d.readNext(values, offset, length);\n} catch (ParquetDecodingException e) {\n    throw new DataCorruptionException(\"Bad RLE header in INT64 column, re-export file\", e);\n}","handlingStrategy":"try-catch","validationCode":"// Read the footer first; it fails fast on truncation/corruption\nParquetMetadata meta = MetadataReader.readFooter(dataSource, fileSize);\nlong expectedRows = meta.getBlocks().stream().mapToLong(BlockMetaData::getRowCount).sum();","typeGuard":null,"tryCatchPattern":"try {\n    decoder.readNext(values, offset, length);\n} catch (ParquetDecodingException e) {\n    throw new PrestoException(PARQUET_CORRUPT_DATA,\n        \"Bad RLE mode in INT64 column of \" + dataSource.getId(), e);\n}","preventionTips":["Run parquet-tools meta/dump as a post-write validation step.","Rewrite columns with plain encoding if dictionary pages keep failing.","Keep writer and reader Parquet library versions compatible.","Enable checksumming (HDFS) or etag verification (S3) to catch corrupt transfers."],"tags":["parquet","decoding","dictionary-encoding","rle-encoding"],"backgroundTag":"parquet-decoding-failed","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"}