{"record":{"id":"30f4253ed8384e5d","repo":"prestodb/presto","slug":"not-an-orc-file","errorCode":null,"errorMessage":"Not an ORC file","messagePattern":"Not an ORC file","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/cache/StorageOrcFileTailSource.java","lineNumber":93,"sourceCode":"        // Read the tail of the file\n        byte[] buffer = new byte[toIntExact(min(size, expectedFooterSizeInBytes))];\n        orcDataSource.readFully(size - buffer.length, buffer);\n\n        // get length of PostScript - last byte of the file\n        int postScriptSize = buffer[buffer.length - SIZE_OF_BYTE] & 0xff;\n        if (postScriptSize >= buffer.length) {\n            throw new OrcCorruptionException(orcDataSource.getId(), \"Invalid postscript length %s\", postScriptSize);\n        }\n\n        // decode the post script\n        PostScript postScript;\n        try {\n            postScript = metadataReader.readPostScript(buffer, buffer.length - SIZE_OF_BYTE - postScriptSize, postScriptSize);\n        }\n        catch (OrcCorruptionException e) {\n            // check if this is an ORC file and not an RCFile or something else\n            if (!isValidHeaderMagic(orcDataSource)) {\n                throw new OrcCorruptionException(orcDataSource.getId(), \"Not an ORC file\");\n            }\n            throw e;\n        }\n\n        // verify this is a supported version\n        checkOrcVersion(orcDataSource, postScript.getVersion());\n        validateWrite(writeValidation, orcDataSource, validation -> validation.getVersion().equals(postScript.getVersion()), \"Unexpected version\");\n\n        int bufferSize = toIntExact(postScript.getCompressionBlockSize());\n\n        // check compression codec is supported\n        CompressionKind compressionKind = postScript.getCompression();\n        validateWrite(writeValidation, orcDataSource, validation -> validation.getCompression() == compressionKind, \"Unexpected compression\");\n\n        PostScript.HiveWriterVersion hiveWriterVersion = postScript.getHiveWriterVersion();\n\n        int footerSize = toIntExact(postScript.getFooterLength());\n        int metadataSize = toIntExact(postScript.getMetadataLength());","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/cache/StorageOrcFileTailSource.java#L75-L111","documentation":"When parsing the PostScript fails with OrcCorruptionException, the library checks the file's leading magic bytes. If the header is not the valid 'ORC' magic, it rethrows a clearer 'Not an ORC file' error instead of the low-level parse failure. This indicates the data source is not ORC format at all.","triggerScenarios":"metadataReader.readPostScript throws inside getOrcFileTail and isValidHeaderMagic(orcDataSource) returns false — i.e. the first bytes are not the ORC magic.","commonSituations":"Pointing a connector at RCFiles, Avro, Parquet, sequence files, or text data; reading a directory listing placeholder; a file renamed/symlinked incorrectly.","solutions":["Confirm the file format (file command / first 3 bytes) and use the matching reader for Parquet, Avro, RCFile, etc.","Fix the table/connector format configuration so the path points to ORC output.","Re-run the job that was supposed to produce ORC output; the file may be a leftover from a different format.","If the file was converted in-place, restore the original ORC version."],"exampleFix":"// before\nSchemaTableName table = new SchemaTableName(\"sales\", \"events\"); // hive table with format=RCFILE but query expects ORC\n// after\nALTER TABLE sales.events SET FILEFORMAT ORC; -- or point query at the correct ORC table","handlingStrategy":"validation","validationCode":"byte[] magic = new byte[3];\norcDataSource.readFully(0, magic);\nif (!Arrays.equals(magic, \"ORC\".getBytes(StandardCharsets.US_ASCII))) {\n    throw new SkipFileException(\"Not an ORC file: \" + orcDataSource.getId());\n}","typeGuard":null,"tryCatchPattern":"try { tail = source.getOrcFileTail(ds, reader, Optional.empty(), false, time); }\ncatch (OrcCorruptionException e) {\n    // e.getMessage() contains \"Not an ORC file\" -> route to correct format reader\n}","preventionTips":["Confirm table file format in metastore matches actual files","Don't mix RCFile/Avro/Parquet paths into ORC tables","Spot-check magic bytes when ingesting external data"],"tags":["orc","wrong-format","magic-header"],"backgroundTag":"not-an-orc-file","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"}