prestodb/presto · error · PrestoException
HIVE_CANNOT_OPEN_SPLIT
HIVE_CANNOT_OPEN_SPLIT
Error message
Error opening Hive split %s (offset=%s, length=%s) using %s: %s
What it means
A generic failure while opening a Hive split's input format: any IOException from createRecordReader that is not the line-length case is wrapped as HIVE_CANNOT_OPEN_SPLIT, including the split path, offset, length, input format class, and underlying message. It means the connector could not instantiate or initialize the record reader for that split.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveUtil.java:323
int headerCount = getHeaderCount(schema);
// Only skip header rows when the split is at the beginning of the file
if (start == 0 && headerCount > 0) {
Utilities.skipHeader(recordReader, headerCount, recordReader.createKey(), recordReader.createValue());
}
int footerCount = getFooterCount(schema);
if (footerCount > 0) {
recordReader = new FooterAwareRecordReader<>(recordReader, footerCount, jobConf);
}
return recordReader;
}
catch (IOException e) {
if (e instanceof TextLineLengthLimitExceededException) {
throw new PrestoException(HIVE_BAD_DATA, "Line too long in text file: " + path, e);
}
throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, format("Error opening Hive split %s (offset=%s, length=%s) using %s: %s",
path,
start,
length,
getInputFormatName(schema),
firstNonNull(e.getMessage(), e.getClass().getName())),
e);
}
}
public static void setReadColumns(Configuration configuration, List<Integer> readHiveColumnIndexes)
{
configuration.set(READ_COLUMN_IDS_CONF_STR, Joiner.on(',').join(readHiveColumnIndexes));
configuration.setBoolean(READ_ALL_COLUMNS, false);
}
public static Optional<CompressionCodec> getCompressionCodec(TextInputFormat inputFormat, Path file)
{
CompressionCodecFactory compressionCodecFactory;View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the file exists and is readable at the reported path (hdfs dfs -ls / aws s3 ls) and check its integrity
- Confirm the file's actual compression matches its extension/format declared by the table
- Re-run the query — transient S3/HDFS errors may resolve; otherwise restore/reproduce the data
- Check the wrapped cause message and the input format name in the error for the true root cause
Example fix
// before CREATE TABLE t (x bigint) WITH (format='TEXTFILE', external_location='s3://bucket/parts') -- files named .gz but not gzip-compressed // after recompress files properly or drop the .gz suffix and set format/compression accordingly
Defensive patterns
Strategy: retry
Validate before calling
if (!fileExists(path) || !isReadable(path)) throw new IllegalStateException("split file missing/unreadable: " + path); Try / catch
try { readSplit(split); } catch (PrestoException e) { if (e.getErrorCode().getCode() == StandardErrorCode.HIVE_CANNOT_OPEN_SPLIT.getCode()) { log.warn("split open failed for {} offset {}", path, offset); /* retry with backoff, then fail with wrapped cause */ } else throw e; } Prevention
- Ensure table input format/compression declared in metadata matches actual files
- Avoid reading while compaction/ETL rewrites files; use consistent snapshots
- Keep S3/HDFS permissions and network paths healthy; monitor for truncated uploads
When it happens
Trigger: Opening a split whose file is missing/corrupt, wrong compression extension vs actual codec, input format class fails to initialize (misconfigured JobConf, permission denied, truncated file, checksum mismatch).
Common situations: Files deleted or moved by compaction while a query reads them; corrupt/truncated files on HDFS/S3; input format configuration errors; S3 permission or throttling issues; mismatched codec extensions (.gz file not gzipped).
Related errors
- HIVE_CANNOT_OPEN_SPLIT
- HIVE_FILESYSTEM_ERROR
- HIVE_FILESYSTEM_ERROR
- HIVE_FILESYSTEM_ERROR
- HIVE_WRITER_CLOSE_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/62a3c2b3a633946b.
Report an issue: GitHub.