apache/iceberg · error · UncheckedIOException

Problem writing to ORC file %s

Error message

Problem writing to ORC file %s

What it means

OrcFileAppender.add writes each record into an ORC VectorizedRowBatch and flushes it to the underlying Writer via addRowBatch when full. Any IOException from that write path is wrapped in UncheckedIOException with the target file location and the original cause, since the append API is not checked-exception based.

Source

Thrown at orc/src/main/java/org/apache/iceberg/orc/OrcFileAppender.java:101

    OrcFile.WriterOptions options = OrcFile.writerOptions(conf).useUTCTimestamp(true);
    if (file instanceof HadoopOutputFile) {
      options.fileSystem(((HadoopOutputFile) file).getFileSystem());
    }
    options.setSchema(orcSchema);
    this.writer = ORC.newFileWriter(file, options, metadata);
    this.valueWriter = newOrcRowWriter(schema, orcSchema, createWriterFunc);
  }

  @Override
  public void add(D datum) {
    try {
      valueWriter.write(datum, batch);
      if (batch.size == this.batchSize) {
        writer.addRowBatch(batch);
        batch.reset();
      }
    } catch (IOException ioe) {
      throw new UncheckedIOException(
          String.format("Problem writing to ORC file %s", file.location()), ioe);
    }
  }

  @Override
  public Metrics metrics() {
    Preconditions.checkState(isClosed, "Cannot return metrics while appending to an open file.");
    return OrcMetrics.fromWriter(writer, valueWriter.metrics(), metricsConfig);
  }

  @Override
  public long length() {
    if (isClosed) {
      return file.toInputFile().getLength();
    }

    long estimateMemory = writer.estimateMemory();

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the wrapped IOException cause for the storage-level problem (full disk, permission, throttling) and fix that underlying issue.
  2. Check available disk space/quota on the target filesystem and free space or redirect output to a writable location.
  3. Retry the write task; make the write idempotent so a partially written file is discarded and rewritten.

Example fix

// before
try (FileAppender<Record> app = ORC.write(outputFile).schema(schema).build()) {
  app.add(record); // UncheckedIOException: Problem writing to ORC file ...
}
// after: pre-check writable space/permissions and handle the cause
try (FileAppender<Record> app = ORC.write(outputFile).schema(schema).build()) {
  app.add(record);
} catch (UncheckedIOException e) {
  LOG.error("ORC write failed for {}: {}", e.getMessage(), e.getCause());
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight writable check
if (!Files.getDefaultFileSystemProvider() /* or FS API */.getFileSystem(...).getUsed() /* capacity check */) {
  throw new IllegalStateException("Insufficient space for ORC output");
}

Try / catch

try {
  appender.add(record);
} catch (UncheckedIOException e) {
  Throwable cause = e.getCause(); // diagnose storage-level failure
  LOG.error("ORC append failed: {} / {}", e.getMessage(), cause.getMessage());
  throw e;
}

Prevention

When it happens

Trigger: Calling appender.add(record) (or addAll) when the underlying ORC Writer fails to flush a row batch: disk full, filesystem/network errors (S3/HDFS interruptions), permission issues, or a record whose value fails ORC serialization inside the writer.

Common situations: Insufficient disk/quota on local or distributed storage while writing a large ORC file; transient cloud-storage failures; writing to a path the process lacks write permission for.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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