apache/iceberg · info · UnsupportedOperationException

seekToNewSource not supported

Error message

seekToNewSource not supported

What it means

HadoopStreams' SeekableInputStream wrapper does not implement seekToNewSource and always throws UnsupportedOperationException. seekToNewSource (HDFS locality re-read from a different replica) is not part of the abstraction this wrapper provides.

Source

Thrown at core/src/main/java/org/apache/iceberg/hadoop/HadoopStreams.java:231

    private final SeekableInputStream inputStream;

    private WrappedSeekableInputStream(SeekableInputStream inputStream) {
      this.inputStream = inputStream;
    }

    @Override
    public void seek(long pos) throws IOException {
      inputStream.seek(pos);
    }

    @Override
    public long getPos() throws IOException {
      return inputStream.getPos();
    }

    @Override
    public boolean seekToNewSource(long targetPos) throws IOException {
      throw new UnsupportedOperationException("seekToNewSource not supported");
    }

    @Override
    public int read() throws IOException {
      return inputStream.read();
    }

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
      return inputStream.read(b, off, len);
    }

    @Override
    public void close() throws IOException {
      inputStream.close();
    }

    @Override

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Avoid calling seekToNewSource; use seek(pos) and read() instead
  2. Handle UnsupportedOperationException and retry reads via seek(0)/re-open the file rather than seeking to a new source
  3. If HDFS-locality fallback is required, use the raw HDFS FSDataInputStream instead of the wrapped Iceberg stream

Example fix

// before
in.seekToNewSource(targetPos); // throws
// after
try { in.seekToNewSource(targetPos); }
catch (UnsupportedOperationException e) { in.seek(0); /* re-read from start */ }
Defensive patterns

Strategy: fallback

Try / catch

try { in.seekToNewSource(pos); }
catch (UnsupportedOperationException e) {
  in.seek(0); // or re-open the file and re-read
}

Prevention

When it happens

Trigger: Any code path calling seekToNewSource(targetPos) on a stream obtained from HadoopStreams.wrap(...) — typically Hadoop/HDFS reader internals or checksum-retry logic falling back to a new source.

Common situations: HDFS ReadCallbacks or FileSystem-level retry code invoking seekToNewSource after block read failures; generic code written against org.apache.hadoop.fs.Seekable assuming full Seekable support.

Related errors


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