{"record":{"id":"21313d123ceb0adf","repo":"prestodb/presto","slug":"hive-bad-data-21313d","errorCode":"HIVE_BAD_DATA","errorMessage":"ORC file is empty: ","messagePattern":"ORC file is empty: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/orc/DwrfBatchPageSourceFactory.java","lineNumber":108,"sourceCode":"            Configuration configuration,\n            ConnectorSession session,\n            HiveFileSplit fileSplit,\n            Storage storage,\n            SchemaTableName tableName,\n            Map<String, String> tableParameters,\n            List<HiveColumnHandle> columns,\n            TupleDomain<HiveColumnHandle> effectivePredicate,\n            DateTimeZone hiveStorageTimeZone,\n            HiveFileContext hiveFileContext,\n            Optional<EncryptionInformation> encryptionInformation,\n            Optional<byte[]> rowIDPartitionComponent)\n    {\n        if (!OrcSerde.class.getName().equals(storage.getStorageFormat().getSerDe())) {\n            return Optional.empty();\n        }\n\n        if (fileSplit.getFileSize() == 0) {\n            throw new PrestoException(HIVE_BAD_DATA, \"ORC file is empty: \" + fileSplit.getPath());\n        }\n\n        return Optional.of(createOrcPageSource(\n                DWRF,\n                hdfsEnvironment,\n                configuration,\n                fileSplit,\n                columns,\n                false,\n                effectivePredicate,\n                session.getSqlFunctionProperties().isLegacyTimestamp() ? hiveStorageTimeZone : DateTimeZone.UTC,\n                typeManager,\n                false,\n                stats,\n                domainCompactionThreshold,\n                orcFileTailSource,\n                stripeMetadataSourceFactory,\n                hiveFileContext,","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/orc/DwrfBatchPageSourceFactory.java#L90-L126","documentation":"Same guard as DwrfAggregatedPageSourceFactory: DwrfBatchPageSourceFactory.createPageSource rejects zero-size ORC/DWRF splits with PrestoException(HIVE_BAD_DATA) because an empty file has no ORC magic/postscript and cannot be read.","triggerScenarios":"A split assigned to this batch page source factory points at a file where fileSplit.getFileSize() == 0, after the OrcSerde check passes.","commonSituations":"Zero-byte files in ORC table directories from failed writers, partial uploads, or rsync/distcp jobs that created placeholders; table partitions pointing at unpopulated locations.","solutions":["Delete the zero-byte file from HDFS (hadoop fs -rm) or repartition the table","Re-run the job that was supposed to write the data","Use a Presto version that tolerates/skips empty ORC files"],"exampleFix":"// before\nSELECT count(*) FROM t; -- HIVE_BAD_DATA: ORC file is empty: /warehouse/t/part-0\n\n// after\n-- hadoop fs -rm /warehouse/t/part-0\nSELECT count(*) FROM t;","handlingStrategy":"validation","validationCode":"# preflight for batch scans\nhadoop fs -ls /warehouse/t/ | awk '$5 == 0 {print \"EMPTY: \" $NF}'","typeGuard":null,"tryCatchPattern":"try {\n    return runBatchQuery(sql);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"HIVE_BAD_DATA\")\n        && e.getMessage().contains(\"ORC file is empty\")) {\n        repairPartition(e.getMessage()); // drop empty files, re-add partition\n        return runBatchQuery(sql);\n    }\n    throw e;\n}","preventionTips":["Use commit protocols (rename-on-commit) so empty placeholders never appear in table paths","Add an ingestion-time assertion that every closed file is non-empty and starts with the ORC magic","Scan for 0-byte files nightly in table locations"],"tags":["orc","hive","empty-file","hdfs","bad-data"],"backgroundTag":"orc-empty-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"}