apache/iceberg · error · RuntimeIOException

Failed to open file: %s

Error message

Failed to open file: %s

What it means

OrcMetrics.fromInputFile opens the ORC file solely to compute file-level metrics (row count, column stats). If the ORC Reader cannot be opened — missing file, corrupt footer, or storage IOException — the exception is wrapped in RuntimeIOException including the file location. Metrics collection is decoupled from actual data reads, so this can surface during commit/metadata operations.

Source

Thrown at orc/src/main/java/org/apache/iceberg/orc/OrcMetrics.java:104

    final Configuration config =
        (file instanceof HadoopInputFile)
            ? ((HadoopInputFile) file).getConf()
            : new Configuration();
    return fromInputFile(file, config, metricsConfig, mapping);
  }

  static Metrics fromInputFile(
      InputFile file, Configuration config, MetricsConfig metricsConfig, NameMapping mapping) {
    try (Reader orcReader = ORC.newFileReader(file, config)) {
      return buildOrcMetrics(
          orcReader.getNumberOfRows(),
          orcReader.getSchema(),
          orcReader.getStatistics(),
          Stream.empty(),
          metricsConfig,
          mapping);
    } catch (IOException ioe) {
      throw new RuntimeIOException(ioe, "Failed to open file: %s", file.location());
    }
  }

  static Metrics fromWriter(
      Writer writer, Stream<FieldMetrics<?>> fieldMetricsStream, MetricsConfig metricsConfig) {
    try {
      return buildOrcMetrics(
          writer.getNumberOfRows(),
          writer.getSchema(),
          writer.getStatistics(),
          fieldMetricsStream,
          metricsConfig,
          null);
    } catch (IOException ioe) {
      throw new RuntimeIOException(ioe, "Failed to get statistics from writer");
    }
  }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Check the wrapped cause and verify the file exists and is a valid ORC file at the given location.
  2. Fix storage access: permissions, credentials, or bucket/path configuration used to build the InputFile.
  3. If the file is corrupt or deleted, remove it from the table/manifest set or rewrite it from a backup; retry transient storage failures.

Example fix

// before
Metrics m = OrcMetrics.fromInputFile(file, metricsConfig, mapping); // RuntimeIOException if unopenable

// after
if (!file.exists()) {
  throw new IllegalStateException("Input file missing: " + file.location());
}
Metrics m = OrcMetrics.fromInputFile(file, metricsConfig, mapping);
Defensive patterns

Strategy: validation

Validate before calling

if (!file.exists()) {
  throw new IllegalStateException("Cannot compute metrics; file missing: " + file.location());
}

Try / catch

try {
  Metrics m = OrcMetrics.fromInputFile(file, metricsConfig, mapping);
} catch (RuntimeIOException e) {
  LOG.error("Cannot open ORC for metrics: {} cause: {}", file.location(), e.getCause());
  throw e;
}

Prevention

When it happens

Trigger: Calling OrcMetrics.fromInputFile(file, metricsConfig, mapping) on an InputFile that fails to open as ORC: file not found, deleted object, truncated/corrupt footer, or storage access error (permissions, credentials, network).

Common situations: Metadata/commit tasks computing metrics for files that expired or were deleted on S3; corrupt ORC files from interrupted writes; wrong path or bucket configuration; missing cloud credentials.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/a5dc56252c2bd15f. Report an issue: GitHub.