{"record":{"id":"c53c0002b9a09a02","repo":"apache/iceberg","slug":"unable-to-read-the-metrics-of-the-parquet-file","errorCode":null,"errorMessage":"Unable to read the metrics of the Parquet file: ","messagePattern":"Unable to read the metrics of the Parquet file: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"data/src/main/java/org/apache/iceberg/data/TableMigrationUtil.java","lineNumber":230,"sourceCode":"  }\n\n  private static Metrics getAvroMetrics(Path path, Configuration conf) {\n    try {\n      InputFile file = HadoopInputFile.fromPath(path, conf);\n      long rowCount = Avro.rowCount(file);\n      return new Metrics(rowCount, null, null, null, null);\n    } catch (UncheckedIOException e) {\n      throw new RuntimeException(\"Unable to read Avro file: \" + path, e);\n    }\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) {","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/data/src/main/java/org/apache/iceberg/data/TableMigrationUtil.java#L212-L248","documentation":"Thrown by TableMigrationUtil.getParquetMetrics when reading column statistics/metrics from a Parquet file during table migration or import fails with an UncheckedIOException. Iceberg wraps the low-level IO failure in a RuntimeException that includes the file path, because import cannot proceed without metrics. The original cause chain is preserved.","triggerScenarios":"Calling TableMigrationUtil.importParquet (or a Spark/Hive migration procedure) on a Parquet path whose underlying file is missing, deleted mid-read, unreadable due to permissions, or whose Hadoop configuration points at an inaccessible filesystem (e.g. wrong defaultFS, missing credentials).","commonSituations":"Migrating a Hive table where files were removed by compaction after planning; S3/HDFS credentials expired; snapshot paths referenced by a stale manifest; typo in warehouse path so the file does not exist.","solutions":["Verify the file path exists and is readable: run hadoop fs -ls / hdfs dfs -ls on the path printed in the message.","Fix Hadoop configuration/credentials for the source filesystem (core-site.xml, S3A keys, tokens) and retry.","If the file was deleted, re-plan the migration against a consistent snapshot or restore the file.","Catch the RuntimeException at the call site to skip/report bad files instead of failing the whole import."],"exampleFix":"// before\nMetrics metrics = TableMigrationUtil.getParquetMetrics(path, conf, metricsSpec, mapping);\n// after\nMetrics metrics;\ntry {\n  metrics = TableMigrationUtil.getParquetMetrics(path, conf, metricsSpec, mapping);\n} catch (RuntimeException e) {\n  LOG.warn(\"Skipping unreadable parquet file {}\", path, e);\n  return;\n}","handlingStrategy":"try-catch","validationCode":"Path p = new Path(parquetPath);\nFileSystem fs = p.getFileSystem(conf);\nPreconditions.checkState(fs.exists(p) && fs.getFileStatus(p).getLen() > 0, \"Missing/unreadable parquet file: \" + parquetPath);","typeGuard":null,"tryCatchPattern":"try {\n  Metrics m = TableMigrationUtil.getParquetMetrics(path, conf, metricsSpec, mapping);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof UncheckedIOException || e.getCause() instanceof IOException) {\n    LOG.warn(\"Skipping unreadable parquet file {}\", path, e);\n  } else { throw e; }\n}","preventionTips":["Verify file existence and permissions with the same Hadoop conf used for import","Keep lifecycle/compaction jobs from deleting files during migration","Test filesystem credentials (S3A keys, Kerberos tokens) before long imports"],"tags":["parquet","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"}