apache/iceberg · error · UncheckedIOException

Failed to read bytes from stream

Error message

Failed to read bytes from stream

What it means

decode() slices totalBytesInStream bytes from the data stream; an EOFException means the stream ended before all encoded byte streams were available, wrapped in UncheckedIOException with this message.

Source

Thrown at arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedByteStreamSplitValuesReader.java:140

  }

  private void ensureDecoded() {
    if (decodedDataStream == null) {
      Preconditions.checkState(
          totalBytesInStream % elementSizeInBytes == 0,
          "Stream size %s is not a multiple of element size %s",
          totalBytesInStream,
          elementSizeInBytes);
      this.decodedDataStream = decode(totalBytesInStream / elementSizeInBytes);
    }
  }

  private ByteBuffer decode(int valuesCount) {
    ByteBuffer encoded;
    try {
      encoded = dataStream.slice(totalBytesInStream).slice();
    } catch (EOFException e) {
      throw new UncheckedIOException("Failed to read bytes from stream", e);
    }
    byte[] decoded = new byte[encoded.limit()];
    int destByteIndex = 0;
    for (int srcValueIndex = 0; srcValueIndex < valuesCount; srcValueIndex++) {
      for (int stream = 0; stream < elementSizeInBytes; stream++, destByteIndex++) {
        decoded[destByteIndex] = encoded.get(srcValueIndex + stream * valuesCount);
      }
    }
    return ByteBuffer.wrap(decoded).order(ByteOrder.LITTLE_ENDIAN);
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Regenerate or re-fetch the Parquet file — the page is truncated/corrupt.
  2. Retry if the cause was a transient network/object-store read failure.
  3. Validate files after write (checksum) to catch truncation early.
Defensive patterns

Strategy: retry

Try / catch

// catch (UncheckedIOException e) {
//   if (e.getCause() instanceof EOFException) { refetchOrRegenerateFile(); }
//   else throw e;
// }

Prevention

When it happens

Trigger: BYTE_STREAM_SPLIT page truncated relative to totalBytesInStream (valuesCount * elementSizeInBytes streams missing bytes) during ensureDecoded.

Common situations: Truncated Parquet files from aborted writes, S3 reads interrupted mid-object, wrong page-size metadata.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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