{
  "schemaVersion": "1.0",
  "canonicalPage": "https://fileformat.co/ext/orc",
  "inspectorUrl": "https://fileformat.co/inspect",
  "spec": {
    "slug": "orc",
    "extension": ".orc",
    "aliases": [],
    "name": "Apache ORC (Optimized Row Columnar)",
    "shortName": "Apache ORC",
    "category": "data-lake",
    "tier": 2,
    "summary": "Stripe-based columnar storage format originating in the Hive/Trino/Presto ecosystem with Protobuf-encoded Footer and a 1-byte PostScript length at the very last byte of the file.",
    "technicalNotes": "Starts with 3-byte ASCII `ORC` (`4F 52 43`). The final byte (`EOF - 1`) gives the uncompressed PostScript length (always < 256 bytes).",
    "mimeTypes": [
      "application/vnd.apache.orc",
      "application/octet-stream"
    ],
    "identifiers": {
      "specUrl": "https://orc.apache.org/specification/ORCv1/"
    },
    "binarySignature": {
      "endianness": "little",
      "magicBytes": [
        {
          "offset": 0,
          "hex": "4F 52 43",
          "ascii": "ORC",
          "description": "3-byte ASCII 'ORC' file header"
        }
      ],
      "containerFamily": null,
      "headerLayout": [
        {
          "offset": "0x00 - 0x02",
          "byteOffset": 0,
          "byteLength": 3,
          "lengthLabel": "3 B",
          "dataType": "char[3]",
          "fieldName": "magic",
          "description": "ASCII 'ORC' header"
        },
        {
          "offset": "0x03 ..",
          "byteOffset": 3,
          "byteLength": 16,
          "lengthLabel": "var",
          "dataType": "stripes",
          "fieldName": "stripe_data",
          "description": "Index, data, and stripe footer streams"
        },
        {
          "offset": "EOF-1",
          "byteOffset": 20,
          "byteLength": 1,
          "lengthLabel": "1 B",
          "dataType": "uint8",
          "fieldName": "postscript_len",
          "description": "Byte length of uncompressed PostScript message"
        }
      ]
    },
    "securityProfile": {
      "riskLevel": "low",
      "allowsArbitraryCodeOrMacros": false,
      "xxeRisk": false,
      "polyglotPrependRisk": false,
      "pickleDeserializationRisk": false,
      "uploadValidationNotes": "Check head[0:3] == 'ORC' and verify that the PostScript struct preceding EOF-1 ends with 'ORC'."
    },
    "codeSnippets": {
      "python": "import os, sys\nwith open(sys.argv[1], \"rb\") as f:\n    assert f.read(3) == b\"ORC\"\n    f.seek(-1, os.SEEK_END)\n    ps_len = f.read(1)[0]\n    print(f\"ORC valid: postscript_len={ps_len}B\")",
      "typescript": "export async function checkOrc(file: File) {\n  const head = new TextDecoder().decode(await file.slice(0, 3).arrayBuffer());\n  const psLen = new Uint8Array(await file.slice(file.size - 1).arrayBuffer())[0];\n  return { valid: head === 'ORC', psLen };\n}",
      "rust": "use std::{fs::File, io::Read};\nfn main() -> std::io::Result<()> {\n    let mut b = [0u8; 3];\n    File::open(std::env::args().nth(1).expect(\"usage: <prog> <file>\"))?.read_exact(&mut b)?;\n    println!(\"ORC header: {}\", String::from_utf8_lossy(&b));\n    Ok(())\n}",
      "go": "package main\nimport (\"fmt\"; \"io\"; \"os\")\nfunc main() {\n    f, err := os.Open(os.Args[1])\n    if err != nil {\n        fmt.Fprintln(os.Stderr, \"open:\", err)\n        os.Exit(1)\n    }\n    defer f.Close()\n    b := make([]byte, 3)\n    if _, err := io.ReadFull(f, b); err != nil {\n        fmt.Fprintln(os.Stderr, \"read:\", err)\n        os.Exit(1)\n    }\n    fmt.Println(string(b))\n}"
    },
    "relatedFormats": [
      "parquet",
      "avro",
      "arrow"
    ],
    "verifiedAt": "2026-11-14T16:09:03Z"
  },
  "samples": [
    {
      "id": "orc-minimal",
      "filename": "minimal-stripe.orc",
      "variant": "minimal",
      "title": "Minimal Apache ORC Stripe File",
      "description": "Real ORC file written by pyarrow.orc: ORC magic, single stripe, Footer + PostScript trailer.",
      "localPath": "/fixtures/v1/orc/minimal-stripe.orc",
      "cdnUrl": "https://fileformat.co/fixtures/v1/orc/minimal-stripe.orc",
      "sizeBytes": 344,
      "sha256": "09713ef2158b8196359189b71dc332a3e57f8203547a2926a4bd3d0407f1ce0e",
      "expectValid": true
    },
    {
      "id": "orc-realistic",
      "filename": "warehouse-stripe.orc",
      "variant": "realistic",
      "title": "ORC Columnar Stripe Fixture",
      "description": "200-row ORC file from pyarrow.orc for Hive/Trino/Spark reader identification tests.",
      "localPath": "/fixtures/v1/orc/warehouse-stripe.orc",
      "cdnUrl": "https://fileformat.co/fixtures/v1/orc/warehouse-stripe.orc",
      "sizeBytes": 2915,
      "sha256": "53afde4eadd2f23134d25a33b5b7418de973fc6996d3aeb39a20f2095b5e066c",
      "expectValid": true
    },
    {
      "id": "orc-edge-case",
      "filename": "truncated-postscript.orc",
      "variant": "edge-case",
      "title": "Truncated ORC PostScript Trailer",
      "description": "ORC file missing the trailing PostScript tail — pyarrow ORCFile must raise.",
      "localPath": "/fixtures/v1/orc/truncated-postscript.orc",
      "cdnUrl": "https://fileformat.co/fixtures/v1/orc/truncated-postscript.orc",
      "sizeBytes": 339,
      "sha256": "8dd70b083ac96f1241bf50e890d1e5126bbd49910ad9cb927a00111ba693a2da",
      "expectValid": false,
      "edgeCaseTag": "Truncated PostScript"
    }
  ]
}