{"record":{"id":"38fb17d00a1a0a67","repo":"apache/iceberg","slug":"unable-to-read-the-metrics-of-the-orc-file","errorCode":null,"errorMessage":"Unable to read the metrics of the Orc file: ","messagePattern":"Unable to read the metrics of the Orc file: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"data/src/main/java/org/apache/iceberg/data/TableMigrationUtil.java","lineNumber":239,"sourceCode":"    }\n  }\n\n  private static Metrics getParquetMetrics(\n      Path path, Configuration conf, MetricsConfig metricsSpec, NameMapping mapping) {\n    try {\n      InputFile file = HadoopInputFile.fromPath(path, conf);\n      return ParquetUtil.fileMetrics(file, metricsSpec, mapping);\n    } catch (UncheckedIOException e) {\n      throw new RuntimeException(\"Unable to read the metrics of the Parquet file: \" + path, e);\n    }\n  }\n\n  private static Metrics getOrcMetrics(\n      Path path, Configuration conf, MetricsConfig metricsSpec, NameMapping mapping) {\n    try {\n      return OrcMetrics.fromInputFile(HadoopInputFile.fromPath(path, conf), metricsSpec, mapping);\n    } catch (UncheckedIOException e) {\n      throw new RuntimeException(\"Unable to read the metrics of the Orc file: \" + path, e);\n    }\n  }\n\n  private static DataFile buildDataFile(\n      FileStatus stat,\n      List<String> partitionValues,\n      PartitionSpec spec,\n      Metrics metrics,\n      String format) {\n    return DataFiles.builder(spec)\n        .withPath(stat.getPath().toString())\n        .withFormat(format)\n        .withFileSizeInBytes(stat.getLen())\n        .withMetrics(metrics)\n        .withPartitionValues(partitionValues)\n        .build();\n  }\n","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/data/src/main/java/org/apache/iceberg/data/TableMigrationUtil.java#L221-L257","documentation":"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.","triggerScenarios":"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.","commonSituations":"ORC files deleted or rewritten between listing and reading; misconfigured object-store endpoint; Hive table pointing to a location the migration user cannot read.","solutions":["Check the ORC file path from the error message exists and is readable with the current Hadoop configuration.","Fix filesystem credentials/endpoint configuration (e.g. S3A/HDFS settings) and retry the migration.","Re-list or restore the missing file if it was deleted by compaction or lifecycle rules.","Handle per-file failures in the migration job so one bad file does not abort the whole import."],"exampleFix":"// before\nMetrics metrics = TableMigrationUtil.getOrcMetrics(path, conf, metricsSpec, mapping);\n// after\ntry {\n  Metrics metrics = TableMigrationUtil.getOrcMetrics(path, conf, metricsSpec, mapping);\n} catch (RuntimeException e) {\n  LOG.warn(\"Unreadable ORC file {}, excluding from import\", path);\n}","handlingStrategy":"try-catch","validationCode":"Path p = new Path(orcPath);\nFileSystem fs = p.getFileSystem(conf);\nPreconditions.checkState(fs.exists(p), \"Missing ORC file: \" + orcPath);","typeGuard":null,"tryCatchPattern":"try {\n  Metrics m = TableMigrationUtil.getOrcMetrics(path, conf, metricsSpec, mapping);\n} catch (RuntimeException e) {\n  LOG.warn(\"Skipping unreadable ORC file {}\", path, e);\n}","preventionTips":["Freeze source table changes (compaction, deletes) during migration","Validate source paths before starting the import","Fix object-store endpoint/credentials in Hadoop conf first"],"tags":["orc","io","migration","file-read"],"backgroundTag":"file-read-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}