apache/iceberg · error · ValidationException

Cannot get metrics from file format

Error message

Cannot get metrics from file format: %s

What it means

getMetricsForFile computes column metrics for a Delta data file and only implements Parquet (via ParquetUtil.fileMetrics). If the file's FileFormat is anything else it throws this ValidationException, since no metrics extractor is wired for other formats.

Solutions

  1. Ensure all Delta data files are Parquet; convert otherwise before snapshotting.
  2. If you extended determineFileFormatFromPath, add a matching branch calling the correct metrics utility (e.g. OrcUtil.fileMetrics) before this throw.
  3. Do not call getMetricsForFile directly with non-Parquet formats in custom code.

Example fix

// before
throw new ValidationException("Cannot get metrics from file format: %s", format);
// after
if (format == FileFormat.ORC) {
  return OrcUtil.fileMetrics(file, metricsSpec, mapping);
}
throw new ValidationException("Cannot get metrics from file format: %s", format);
Defensive patterns

Strategy: validation

Validate before calling

if (format != FileFormat.PARQUET) {
  throw new IllegalStateException("Metrics only supported for PARQUET, got " + format);
}

Prevention

When it happens

Trigger: Only reachable if determineFileFormatFromPath or a modified code path returns a non-PARQUET FileFormat for a Delta data file — e.g. after extending the format mapping to ORC/Avro without adding metrics support, or custom subclasses calling getMetricsForFile with another format.

Common situations: Forked/patched code adding ORC or Avro Delta files without a corresponding metrics implementation; unit tests invoking getMetricsForFile with unsupported formats.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at delta-lake/src/main/java/org/apache/iceberg/delta/BaseSnapshotDeltaLakeTableAction.java:416

        .withMetrics(metrics)
        .withPartitionValues(partitionValueList)
        .build();
  }

  private FileFormat determineFileFormatFromPath(String path) {
    if (path.endsWith(PARQUET_SUFFIX)) {
      return FileFormat.PARQUET;
    } else {
      throw new ValidationException("Do not support file format in path %s", path);
    }
  }

  private Metrics getMetricsForFile(
      InputFile file, FileFormat format, MetricsConfig metricsSpec, NameMapping mapping) {
    if (format == FileFormat.PARQUET) {
      return ParquetUtil.fileMetrics(file, metricsSpec, mapping);
    }
    throw new ValidationException("Cannot get metrics from file format: %s", format);
  }

  private Map<String, String> destTableProperties(
      io.delta.standalone.Snapshot deltaSnapshot, String originalLocation) {
    additionalPropertiesBuilder.putAll(deltaSnapshot.getMetadata().getConfiguration());
    additionalPropertiesBuilder.putAll(
        ImmutableMap.of(
            SNAPSHOT_SOURCE_PROP, DELTA_SOURCE_VALUE, ORIGINAL_LOCATION_PROP, originalLocation));

    return additionalPropertiesBuilder.build();
  }

  private void tagCurrentSnapshot(long deltaVersion, Transaction transaction) {
    long currentSnapshotId = transaction.table().currentSnapshot().snapshotId();

    ManageSnapshots manageSnapshots = transaction.manageSnapshots();
    manageSnapshots.createTag(DELTA_VERSION_TAG_PREFIX + deltaVersion, currentSnapshotId);

View on GitHub (pinned to 86d9c8fc54)