prestodb/presto · error · PrestoException

HIVE_CANNOT_OPEN_SPLIT

HIVE_CANNOT_OPEN_SPLIT

Error message

Error opening Hive split %s (offset=%s, length=%s): %s

What it means

Thrown by RcFilePageSourceFactory.createPageSource when the HDFS/Hive connector cannot open an RCFile split. Any exception raised while calling hdfsEnvironment.getFileSystem(...).openFile(path, ...) is wrapped in a PrestoException with error code HIVE_CANNOT_OPEN_SPLIT; FileNotFoundException and 'Filesystem closed' are wrapped without the split message, everything else gets the formatted splitError message. It signals the split could not be read at all — an infrastructure/availability problem rather than corrupt data.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/rcfile/RcFilePageSourceFactory.java:137

        else {
            return Optional.empty();
        }

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

        FSDataInputStream inputStream;
        Path path = new Path(fileSplit.getPath());
        try {
            inputStream = hdfsEnvironment.getFileSystem(session.getUser(), path, configuration).openFile(path, hiveFileContext);
        }
        catch (Exception e) {
            if (nullToEmpty(e.getMessage()).trim().equals("Filesystem closed") ||
                    e instanceof FileNotFoundException) {
                throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, e);
            }
            throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, splitError(e, fileSplit), e);
        }

        try {
            ImmutableMap.Builder<Integer, Type> readColumns = ImmutableMap.builder();
            for (HiveColumnHandle column : columns) {
                readColumns.put(column.getHiveColumnIndex(), column.getHiveType().getType(typeManager));
            }

            RcFileReader rcFileReader = new RcFileReader(
                    new HdfsRcFileDataSource(path.toString(), inputStream, fileSplit.getFileSize(), stats),
                    rcFileEncoding,
                    readColumns.build(),
                    new AircompressorCodecFactory(new HadoopCodecFactory(configuration.getClassLoader())),
                    fileSplit.getStart(),
                    fileSplit.getLength(),
                    new DataSize(8, Unit.MEGABYTE));

            return Optional.of(new RcFilePageSource(rcFileReader, columns, typeManager));

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the HDFS file exists and is readable: run `hdfs dfs -ls <path>` and `hdfs dfs -cat <file> | head` as the presto user.
  2. Check NameNode health and that the worker's core-site/hdfs-site config points at the right cluster.
  3. Confirm the presto user has read permission (or appropriate Kerberos/HDFS ACLs) on the file and its parents.
  4. If 'Filesystem closed', restart the affected workers / upgrade — the cached FileSystem instance was closed underneath the connector.
  5. Re-run the query; if the file was deleted mid-query, regenerate the data or rerun against an intact snapshot.

Example fix

// before: querying a path that no longer exists
SELECT * FROM hive.default.rc_table; -- fails HIVE_CANNOT_OPEN_SPLIT, file deleted
// after: verify location, or exclude the bad partition
ALTER TABLE hive.default.rc_table DROP IF EXISTS PARTITION (ds='2026-01-01');
SELECT * FROM hive.default.rc_table WHERE ds <> '2026-01-01';
Defensive patterns

Strategy: try-catch

Validate before calling

// before running the query, from a node with the same Hadoop config/user:
// hdfs dfs -test -e <split-path> && hdfs dfs -cat <split-path>/part | head -c 1
Process p = new ProcessBuilder("hdfs", "dfs", "test", "-e", splitPath).start();
if (p.waitFor() != 0) throw new IllegalStateException("HDFS path not readable: " + splitPath);

Type guard

boolean isCannotOpenSplit(Throwable t) {
    return t instanceof PrestoException && ((PrestoException) t).getErrorCode().getName().equals("HIVE_CANNOT_OPEN_SPLIT");
}

Try / catch

try {
    return query(sql);
} catch (PrestoException e) {
    if (e.getErrorCode().getCode() == StandardErrorCode.EXTERNAL.getCode() && e.getMessage() != null && e.getMessage().contains("HIVE_CANNOT_OPEN_SPLIT")) {
        // check HDFS health / file existence, then retry once or fail fast
        throw new TransientQueryException("Split unreadable, check HDFS/file: " + e.getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Presto worker executes createPageSource for an RCFile (RCFileColumnarSerDe or LazyBinaryColumnarSerDe table) and openFile throws: NameNode unreachable, permission denied on the HDFS path, FileNotFoundException because the file was deleted between split scheduling and read, a cached Hadoop FileSystem instance already closed, or any other IOException from the Hadoop FS layer.

Common situations: HDFS NameNode in safe mode or down; underlying table/partition files dropped by a compaction or retention job while a query was running; wrong dfs permissions or missing Kerberos tokens for the presto user; Hive metastore pointing at stale locations; 'Filesystem closed' after a FileSystem cache invalidation in long-lived workers.

Related errors


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