apache/iceberg · error · RuntimeException

Unable to read the metrics of the Orc file:

Error message

Unable to read the metrics of the Orc file: 

What it means

Thrown by TableMigrationUtil.getOrcMetrics when reading metrics from an ORC file during import/migration fails with an UncheckedIOException. Iceberg rethrows it with the file path so the operator knows which object could not be read. Metrics are required to build the DataFile, so the failure aborts the import of that file.

Source

Thrown at data/src/main/java/org/apache/iceberg/data/TableMigrationUtil.java:239

    }
  }

  private static Metrics getParquetMetrics(
      Path path, Configuration conf, MetricsConfig metricsSpec, NameMapping mapping) {
    try {
      InputFile file = HadoopInputFile.fromPath(path, conf);
      return ParquetUtil.fileMetrics(file, metricsSpec, mapping);
    } catch (UncheckedIOException e) {
      throw new RuntimeException("Unable to read the metrics of the Parquet file: " + path, e);
    }
  }

  private static Metrics getOrcMetrics(
      Path path, Configuration conf, MetricsConfig metricsSpec, NameMapping mapping) {
    try {
      return OrcMetrics.fromInputFile(HadoopInputFile.fromPath(path, conf), metricsSpec, mapping);
    } catch (UncheckedIOException e) {
      throw new RuntimeException("Unable to read the metrics of the Orc file: " + path, e);
    }
  }

  private static DataFile buildDataFile(
      FileStatus stat,
      List<String> partitionValues,
      PartitionSpec spec,
      Metrics metrics,
      String format) {
    return DataFiles.builder(spec)
        .withPath(stat.getPath().toString())
        .withFormat(format)
        .withFileSizeInBytes(stat.getLen())
        .withMetrics(metrics)
        .withPartitionValues(partitionValues)
        .build();
  }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Check the ORC file path from the error message exists and is readable with the current Hadoop configuration.
  2. Fix filesystem credentials/endpoint configuration (e.g. S3A/HDFS settings) and retry the migration.
  3. Re-list or restore the missing file if it was deleted by compaction or lifecycle rules.
  4. Handle per-file failures in the migration job so one bad file does not abort the whole import.

Example fix

// before
Metrics metrics = TableMigrationUtil.getOrcMetrics(path, conf, metricsSpec, mapping);
// after
try {
  Metrics metrics = TableMigrationUtil.getOrcMetrics(path, conf, metricsSpec, mapping);
} catch (RuntimeException e) {
  LOG.warn("Unreadable ORC file {}, excluding from import", path);
}
Defensive patterns

Strategy: try-catch

Validate before calling

Path p = new Path(orcPath);
FileSystem fs = p.getFileSystem(conf);
Preconditions.checkState(fs.exists(p), "Missing ORC file: " + orcPath);

Try / catch

try {
  Metrics m = TableMigrationUtil.getOrcMetrics(path, conf, metricsSpec, mapping);
} catch (RuntimeException e) {
  LOG.warn("Skipping unreadable ORC file {}", path, e);
}

Prevention

When it happens

Trigger: Calling TableMigrationUtil.importOrc on an ORC path that does not exist, is inaccessible (permissions, expired credentials), or whose filesystem cannot be opened via HadoopInputFile.fromPath.

Common situations: ORC files deleted or rewritten between listing and reading; misconfigured object-store endpoint; Hive table pointing to a location the migration user cannot read.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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