prestodb/presto · error · PrestoException
HIVE_BAD_DATA
HIVE_BAD_DATA
Error message
ORC file is empty:
What it means
DwrfSelectivePageSourceFactory.createPageSource performs the same zero-length-file check for selective (row-level filtered) ORC scans, throwing PrestoException(HIVE_BAD_DATA) when fileSplit.getFileSize() == 0. After this check it also validates the rowID partition component before building the reader.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/orc/DwrfSelectivePageSourceFactory.java:118
List<HiveColumnHandle> columns,
Map<Integer, String> prefilledValues,
Map<Integer, HiveCoercer> coercers,
Optional<BucketAdaptation> bucketAdaptation,
List<Integer> outputColumns,
TupleDomain<Subfield> domainPredicate,
RowExpression remainingPredicate,
DateTimeZone hiveStorageTimeZone,
HiveFileContext hiveFileContext,
Optional<EncryptionInformation> encryptionInformation,
boolean appendRowNumberEnabled,
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());
}
checkRowIDPartitionComponent(columns, rowIDPartitionComponent);
return Optional.of(createOrcPageSource(
session,
DWRF,
hdfsEnvironment,
configuration,
fileSplit,
columns,
prefilledValues,
coercers,
bucketAdaptation,
outputColumns,
domainPredicate,
remainingPredicate,
false,View on GitHub (pinned to 55bb57d202)
Solutions
- Remove the empty file: hadoop fs -rm <empty-file-path>
- Re-run the producer job to write real data, then refresh the partition
- Verify table location contents: hadoop fs -ls -R <table-location> | grep for 0-size files
Example fix
// before SELECT * FROM t WHERE ds = '2026-01-01'; -- ORC file is empty: /warehouse/t/ds=2026-01-01/f // after -- hadoop fs -rm /warehouse/t/ds=2026-01-01/f -- ALTER TABLE t DROP PARTITION (ds='2026-01-01'); then re-add after data lands SELECT * FROM t WHERE ds = '2026-01-01';
Defensive patterns
Strategy: validation
Validate before calling
# verify selective-scan table location has no empty files
hadoop fs -ls -R /warehouse/t/ | awk '$5 == 0 {print $NF}' Try / catch
try {
return selectiveScan(sql, filters);
} catch (PrestoException e) {
if (e.getErrorCode().getName().equals("HIVE_BAD_DATA")
&& e.getMessage().startsWith("ORC file is empty:")) {
purgeEmptyFiles(tableLocation);
return selectiveScan(sql, filters);
}
throw e;
} Prevention
- Guarantee streaming writers flush initial data or close/delete the file on failure
- Register partitions only after writer commit succeeds
- Alert on zero-byte files in actively queried partitions
When it happens
Trigger: Selective scan (with pushed-down filters or rowId usage) on an ORC/DWRF table where the assigned split's file is 0 bytes.
Common situations: Empty files from failed/partial writes; tables ingested by streaming writers that create the file but crash before the first flush; stale partitions pointing at cleaned directories.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/558f4e18afc231ac.
Report an issue: GitHub.