{"record":{"id":"1d6372b59bb73b5f","repo":"prestodb/presto","slug":"not-a-valid-mode-1d6372","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/FlatDefinitionLevelDecoder.java","lineNumber":74,"sourceCode":"                case RLE: {\n                    boolean rleValue = currentValue == 0;\n                    while (destinationIndex < endIndex) {\n                        values[destinationIndex++] = rleValue;\n                    }\n                    nonNullCount += currentValue * chunkSize;\n                    break;\n                }\n                case PACKED: {\n                    int[] buffer = currentBuffer;\n                    for (int sourceIndex = buffer.length - currentCount; destinationIndex < endIndex; sourceIndex++, destinationIndex++) {\n                        final int value = buffer[sourceIndex];\n                        values[destinationIndex] = value == 0;\n                        nonNullCount += value;\n                    }\n                    break;\n                }\n                default:\n                    throw new ParquetDecodingException(\"not a valid mode \" + mode);\n            }\n            currentCount -= chunkSize;\n            remainingToCopy -= chunkSize;\n        }\n\n        checkState(remainingToCopy == 0, \"Failed to copy the requested number of definition levels\");\n        return nonNullCount;\n    }\n}\n","sourceCodeStart":56,"sourceCodeEnd":84,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/FlatDefinitionLevelDecoder.java#L56-L84","documentation":"FlatDefinitionLevelDecoder.readNext reads definition levels in either RLE or bit-packed mode. When the encoded chunk header contains a mode value other than Mode.RLE or Mode.PACKED_BIT_PACKED, the decoder cannot interpret the data and throws a ParquetDecodingException with the raw mode value. This means the definition-level stream is corrupt, was written by an unsupported writer, or the decoder is being pointed at the wrong byte offset.","triggerScenarios":"readNext() encounters a hybrid (RLE/bit-packed) definition-level chunk whose header mode byte is neither RLE nor PACKED (e.g. mode value 3 or garbage bytes); callers include nonNullCount, rleOnlyBlockHelper, hybridReadInBatchesHelper, and tryReadingTooMany.","commonSituations":"Reading a Parquet file written by a non-conforming writer; truncated or corrupted definition-level column chunk; wrong column metadata offsets after a version change of parquet-mr or the Presto parquet reader; files with experimental/unsupported encodings for definition levels.","solutions":["Verify the Parquet file is readable with parquet-tools/parquet-cli and inspect the definition-level encoding for the affected column","Re-write the file with a standard writer (parquet-mr, Spark, Trino) so definition levels use RLE encoding","Upgrade presto-parquet to a version supporting the file's encoding/mode","If the file is fine, check for misaligned offsets/metadata in the reader path and report a bug with the file and query"],"exampleFix":"// No code fix on caller side; file-level fix:\n// before: file written with unsupported def-level mode in column chunk\n// after: rewrite file so column chunk uses PLAIN + RLE definition levels\n//   e.g. in Spark: df.write.parquet(...) with default parquet writer","handlingStrategy":"validation","validationCode":"// Before querying, validate the file's column chunk encodings with parquet-tools:\n// parquet-tools meta file.parquet | awk '/<target column>/ && $0 !~ /RLE/ {print \"unsupported def-level encoding\", $0}'","typeGuard":null,"tryCatchPattern":"try {\n    recordReader.nextBatch(block);\n} catch (ParquetDecodingException e) {\n    if (e.getMessage().startsWith(\"not a valid mode\")) {\n        // quarantine file, fall back to a repaired copy\n    }\n    throw e;\n}","preventionTips":["Validate files with parquet-tools before registering them in the metastore","Only ingest Parquet written by mainstream writers (Spark/Trino/parquet-mr)","Verify checksums after transfer to catch truncated files","Pin a presto-parquet version compatible with your writer version"],"tags":["parquet","decoding","corrupt-data"],"backgroundTag":"parquet-invalid-encoding-mode","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"}