apache/iceberg · error · UnsupportedOperationException
does not implement length
Error message
${getClass().getName()} does not implement length What it means
SortingPositionOnlyDeleteWriter buffers position-only deletes in memory and sorts them before writing, so it cannot report a stable byte length mid-write; its length() override unconditionally throws UnsupportedOperationException. It is only intended to be queried after result() is obtained.
Solutions
- Call length() only on the DeleteWriteResult or the produced delete files after writer.close()/result(), not on the writer itself
- Check the writer type before querying length, or avoid SortingPositionOnlyDeleteWriter when byte length is needed incrementally
- Get the equivalent size from the resulting DeleteFile(s) metadata after commit
Example fix
// before long len = writer.length(); // after writer.close(); long len = writer.result().deleteFiles().stream().mapToLong(DeleteFile::fileSizeInBytes).sum();
Defensive patterns
Strategy: validation
Validate before calling
if (writer instanceof SortingPositionOnlyDeleteWriter) { /* do not call length() before close */ } Type guard
boolean supportsLength(DeleteWriter<?> w) { return !(w instanceof SortingPositionOnlyDeleteWriter); } Try / catch
try { len = writer.length(); } catch (UnsupportedOperationException e) { len = -1; /* unknown until close */ } Prevention
- Query file sizes from DeleteWriteResult/DeleteFile after close, not from the writer
- Document writer contracts where length is undefined mid-write
- Avoid generic metrics code that assumes all writers implement length()
When it happens
Trigger: Calling length() on a SortingPositionOnlyDeleteWriter at any point (including during write), e.g. generic writer code that measures output size before closing the writer.
Common situations: Framework or metrics code that uniformly calls writer.length() to track file sizes; the sorting writer's size is unknown until deletes are written on close().
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
- Cannot get value for invalid index:
- does not support cardinality
- does not support forEach
- does not support serialize
- Unsupported delete granularity
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/1c98395845c35f8a.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/deletes/SortingPositionOnlyDeleteWriter.java:92
Function<CharSequence, PositionDeleteIndex> loadPreviousDeletes) {
this.writers = writers;
this.granularity = granularity;
this.positionsByPath = CharSequenceMap.create();
this.loadPreviousDeletes = loadPreviousDeletes;
}
@Override
public void write(PositionDelete<T> positionDelete) {
CharSequence path = positionDelete.path();
long position = positionDelete.pos();
PositionDeleteIndex positions =
positionsByPath.computeIfAbsent(path, key -> new BitmapPositionDeleteIndex());
positions.delete(position);
}
@Override
public long length() {
throw new UnsupportedOperationException(getClass().getName() + " does not implement length");
}
@Override
public DeleteWriteResult result() {
return result;
}
@Override
public void close() throws IOException {
if (result == null) {
switch (granularity) {
case FILE:
this.result = writeFileDeletes();
return;
case PARTITION:
this.result = writePartitionDeletes();
return;
default:View on GitHub (pinned to 86d9c8fc54)