prestodb/presto · error · PrestoException

HIVE_BAD_DATA

HIVE_BAD_DATA

Error message

ORC file is empty: 

What it means

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.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/orc/DwrfBatchPageSourceFactory.java:108

            Configuration configuration,
            ConnectorSession session,
            HiveFileSplit fileSplit,
            Storage storage,
            SchemaTableName tableName,
            Map<String, String> tableParameters,
            List<HiveColumnHandle> columns,
            TupleDomain<HiveColumnHandle> effectivePredicate,
            DateTimeZone hiveStorageTimeZone,
            HiveFileContext hiveFileContext,
            Optional<EncryptionInformation> encryptionInformation,
            Optional<byte[]> rowIDPartitionComponent)
    {
        if (!OrcSerde.class.getName().equals(storage.getStorageFormat().getSerDe())) {
            return Optional.empty();
        }

        if (fileSplit.getFileSize() == 0) {
            throw new PrestoException(HIVE_BAD_DATA, "ORC file is empty: " + fileSplit.getPath());
        }

        return Optional.of(createOrcPageSource(
                DWRF,
                hdfsEnvironment,
                configuration,
                fileSplit,
                columns,
                false,
                effectivePredicate,
                session.getSqlFunctionProperties().isLegacyTimestamp() ? hiveStorageTimeZone : DateTimeZone.UTC,
                typeManager,
                false,
                stats,
                domainCompactionThreshold,
                orcFileTailSource,
                stripeMetadataSourceFactory,
                hiveFileContext,

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Delete the zero-byte file from HDFS (hadoop fs -rm) or repartition the table
  2. Re-run the job that was supposed to write the data
  3. Use a Presto version that tolerates/skips empty ORC files

Example fix

// before
SELECT count(*) FROM t; -- HIVE_BAD_DATA: ORC file is empty: /warehouse/t/part-0

// after
-- hadoop fs -rm /warehouse/t/part-0
SELECT count(*) FROM t;
Defensive patterns

Strategy: validation

Validate before calling

# preflight for batch scans
hadoop fs -ls /warehouse/t/ | awk '$5 == 0 {print "EMPTY: " $NF}'

Try / catch

try {
    return runBatchQuery(sql);
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("HIVE_BAD_DATA")
        && e.getMessage().contains("ORC file is empty")) {
        repairPartition(e.getMessage()); // drop empty files, re-add partition
        return runBatchQuery(sql);
    }
    throw e;
}

Prevention

When it happens

Trigger: A split assigned to this batch page source factory points at a file where fileSplit.getFileSize() == 0, after the OrcSerde check passes.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/21313d123ceb0adf. Report an issue: GitHub.