apache/iceberg · error · UnsupportedOperationException

Batch reading is not supported in non-vectorized reader

Error message

Batch reading is not supported in non-vectorized reader

What it means

ParquetFormatModel's ReadBuilder supports batch (vectorized) reading only when the reader was configured as a batch/vectorized reader. Calling recordsPerBatch(int) on a non-vectorized reader throws this UnsupportedOperationException because row-based readers cannot emit batches.

Solutions

  1. Enable the vectorized/batch reader option before calling recordsPerBatch (e.g. set the appropriate ReadBuilder option such as batch format/vectorization)
  2. Remove the recordsPerBatch call when using the non-vectorized reader
  3. Verify reader type: only vectorized readers support batch sizing

Example fix

// before
ReadBuilder rb = io.newReadBuilder().project(schema).recordsPerBatch(1024); // non-vectorized
// after
ReadBuilder rb = io.newReadBuilder()
    .option("batch-format", "arrow") // enables batch reader
    .project(schema)
    .recordsPerBatch(1024);
Defensive patterns

Strategy: validation

Validate before calling

if (!isBatchReader) {
  throw new IllegalStateException("recordsPerBatch requires the vectorized/batch reader");
}

Try / catch

try {
  rb.recordsPerBatch(1024);
} catch (UnsupportedOperationException e) {
  // enable batch reader option or drop the recordsPerBatch call
}

Prevention

When it happens

Trigger: Calling ReadBuilder.recordsPerBatch(numRowsPerBatch) without first calling the option that enables batch/vectorized reading (isBatchReader is false).

Common situations: Configuring record batching for a plain row-oriented record reader; forgetting to enable vectorization (e.g. via a 'batch-format' or vectorization option) before setting batch size.

Related errors


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

Appendix: source

Thrown at parquet/src/main/java/org/apache/iceberg/parquet/ParquetFormatModel.java:391

      return this;
    }

    @Override
    public ReadBuilder<D, S> set(String key, String value) {
      internal.set(key, value);
      return this;
    }

    @Override
    public ReadBuilder<D, S> reuseContainers() {
      internal.reuseContainers();
      return this;
    }

    @Override
    public ReadBuilder<D, S> recordsPerBatch(int numRowsPerBatch) {
      if (!isBatchReader) {
        throw new UnsupportedOperationException(
            "Batch reading is not supported in non-vectorized reader");
      }

      internal.recordsPerBatch(numRowsPerBatch);
      return this;
    }

    @Override
    public ReadBuilder<D, S> idToConstant(Map<Integer, ?> newIdToConstant) {
      this.idToConstant = newIdToConstant;
      return this;
    }

    @Override
    public ReadBuilder<D, S> withNameMapping(NameMapping nameMapping) {
      internal.withNameMapping(nameMapping);
      return this;
    }

View on GitHub (pinned to 86d9c8fc54)