{"record":{"id":"3b1ba8e6dbaffc2a","repo":"apache/iceberg","slug":"cannot-get-metrics-from-file-format-s","errorCode":null,"errorMessage":"Cannot get metrics from file format: %s","messagePattern":"Cannot get metrics from file format: (.+?)","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"delta-lake/src/main/java/org/apache/iceberg/delta/BaseSnapshotDeltaLakeTableAction.java","lineNumber":416,"sourceCode":"        .withMetrics(metrics)\n        .withPartitionValues(partitionValueList)\n        .build();\n  }\n\n  private FileFormat determineFileFormatFromPath(String path) {\n    if (path.endsWith(PARQUET_SUFFIX)) {\n      return FileFormat.PARQUET;\n    } else {\n      throw new ValidationException(\"Do not support file format in path %s\", path);\n    }\n  }\n\n  private Metrics getMetricsForFile(\n      InputFile file, FileFormat format, MetricsConfig metricsSpec, NameMapping mapping) {\n    if (format == FileFormat.PARQUET) {\n      return ParquetUtil.fileMetrics(file, metricsSpec, mapping);\n    }\n    throw new ValidationException(\"Cannot get metrics from file format: %s\", format);\n  }\n\n  private Map<String, String> destTableProperties(\n      io.delta.standalone.Snapshot deltaSnapshot, String originalLocation) {\n    additionalPropertiesBuilder.putAll(deltaSnapshot.getMetadata().getConfiguration());\n    additionalPropertiesBuilder.putAll(\n        ImmutableMap.of(\n            SNAPSHOT_SOURCE_PROP, DELTA_SOURCE_VALUE, ORIGINAL_LOCATION_PROP, originalLocation));\n\n    return additionalPropertiesBuilder.build();\n  }\n\n  private void tagCurrentSnapshot(long deltaVersion, Transaction transaction) {\n    long currentSnapshotId = transaction.table().currentSnapshot().snapshotId();\n\n    ManageSnapshots manageSnapshots = transaction.manageSnapshots();\n    manageSnapshots.createTag(DELTA_VERSION_TAG_PREFIX + deltaVersion, currentSnapshotId);\n","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/delta-lake/src/main/java/org/apache/iceberg/delta/BaseSnapshotDeltaLakeTableAction.java#L398-L434","documentation":"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.","triggerScenarios":"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.","commonSituations":"Forked/patched code adding ORC or Avro Delta files without a corresponding metrics implementation; unit tests invoking getMetricsForFile with unsupported formats.","solutions":["Ensure all Delta data files are Parquet; convert otherwise before snapshotting.","If you extended determineFileFormatFromPath, add a matching branch calling the correct metrics utility (e.g. OrcUtil.fileMetrics) before this throw.","Do not call getMetricsForFile directly with non-Parquet formats in custom code."],"exampleFix":"// before\nthrow new ValidationException(\"Cannot get metrics from file format: %s\", format);\n// after\nif (format == FileFormat.ORC) {\n  return OrcUtil.fileMetrics(file, metricsSpec, mapping);\n}\nthrow new ValidationException(\"Cannot get metrics from file format: %s\", format);","handlingStrategy":"validation","validationCode":"if (format != FileFormat.PARQUET) {\n  throw new IllegalStateException(\"Metrics only supported for PARQUET, got \" + format);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all Delta data files in Parquet.","When extending format support, add the corresponding metrics utility branch.","Only call getMetricsForFile via the standard buildDataFileFromAction path."],"tags":["delta-lake","metrics","unsupported-format"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}