{"record":{"id":"b93fb91b5fd3f68e","repo":"apache/iceberg","slug":"not-implemented-copywithoutstats-b93fb9","errorCode":null,"errorMessage":"Not implemented: copyWithoutStats","messagePattern":"Not implemented: copyWithoutStats","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkContentFile.java","lineNumber":222,"sourceCode":"  public Map<Integer, ByteBuffer> upperBounds() {\n    Map<?, ?> upperBounds =\n        wrapped.isNullAt(upperBoundsPosition) ? null : wrapped.getJavaMap(upperBoundsPosition);\n    return convert(upperBoundsType, upperBounds);\n  }\n\n  @Override\n  public ByteBuffer keyMetadata() {\n    return convert(keyMetadataType, wrapped.get(keyMetadataPosition));\n  }\n\n  @Override\n  public F copy() {\n    throw new UnsupportedOperationException(\"Not implemented: copy\");\n  }\n\n  @Override\n  public F copyWithoutStats() {\n    throw new UnsupportedOperationException(\"Not implemented: copyWithoutStats\");\n  }\n\n  @Override\n  public List<Long> splitOffsets() {\n    return wrapped.isNullAt(splitOffsetsPosition) ? null : wrapped.getList(splitOffsetsPosition);\n  }\n\n  @Override\n  public Integer sortOrderId() {\n    return wrapped.getAs(sortOrderIdPosition);\n  }\n\n  @Override\n  public List<Integer> equalityFieldIds() {\n    return wrapped.isNullAt(equalityIdsPosition) ? null : wrapped.getList(equalityIdsPosition);\n  }\n\n  public String referencedDataFile() {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkContentFile.java#L204-L240","documentation":"SparkContentFile does not implement copyWithoutStats(), the method used to clone a file record while dropping statistics for memory reuse in manifest scanning. Because the wrapper delegates to a shared InternalRow, it cannot cheaply produce a stats-less copy, so it throws UnsupportedOperationException.","triggerScenarios":"Calling copyWithoutStats() on a SparkContentFile/SparkDeleteFile, typically in parallel manifest-reading or delete-file grouping code that holds references and needs stat-free copies.","commonSituations":"Custom scan planning or delete-file loaders built on the Spark wrapper; code copying the ManifestReader pattern of copyWithoutStats onto Spark-backed files.","solutions":["Use core implementations (GenericDataFile / BaseFile) when copyWithoutStats is required.","Read needed fields directly from the wrapper instead of copying.","Wrap results into core file objects before handing them to APIs that call copyWithoutStats."],"exampleFix":"// before\nContentFile<?> statFree = sparkFile.copyWithoutStats(); // throws\n// after\nContentFile<?> statFree = genericDataFile.copyWithoutStats(); // core DataFile","handlingStrategy":"fallback","validationCode":null,"typeGuard":"boolean supportsCopyWithoutStats(org.apache.iceberg.ContentFile<?> f) {\n  return !(f instanceof org.apache.iceberg.spark.SparkContentFile);\n}","tryCatchPattern":"try {\n  statFree = file.copyWithoutStats();\n} catch (UnsupportedOperationException e) {\n  statFree = toCoreDataFile(file).copyWithoutStats();\n}","preventionTips":["Use core DataFile implementations in manifest-scan-like code paths.","Treat SparkContentFile as a read-only view, not a copyable record.","Test custom delete/scan code with Spark wrapper files early."],"tags":["spark","datafile","unsupported-operation"],"backgroundTag":"method-not-implemented","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"}