{"record":{"id":"6f5b0eee9c27bbd2","repo":"apache/iceberg","slug":"batch-reading-is-not-supported-in-non-vectorized-r","errorCode":null,"errorMessage":"Batch reading is not supported in non-vectorized reader","messagePattern":"Batch reading is not supported in non-vectorized reader","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/orc/ORCFormatModel.java","lineNumber":273,"sourceCode":"      return this;\n    }\n\n    @Override\n    public ReadBuilder<D, S> set(String key, String value) {\n      internal.config(key, value);\n      return this;\n    }\n\n    @Override\n    public ReadBuilder<D, S> reuseContainers() {\n      this.reuseContainers = true;\n      return this;\n    }\n\n    @Override\n    public ReadBuilder<D, S> recordsPerBatch(int numRowsPerBatch) {\n      if (!isBatchReader) {\n        throw new UnsupportedOperationException(\n            \"Batch reading is not supported in non-vectorized reader\");\n      }\n\n      internal.recordsPerBatch(numRowsPerBatch);\n      return this;\n    }\n\n    @Override\n    public ReadBuilder<D, S> idToConstant(Map<Integer, ?> newIdToConstant) {\n      internal.constantFieldIds(newIdToConstant.keySet());\n      this.idToConstant = newIdToConstant;\n      return this;\n    }\n\n    @Override\n    public ReadBuilder<D, S> withNameMapping(NameMapping nameMapping) {\n      internal.withNameMapping(nameMapping);\n      return this;","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/ORCFormatModel.java#L255-L291","documentation":"Iceberg's ORC reader can read either rows (generic ORC records) or columnar batches (VectorizedRowBatch). recordsPerBatch() only makes sense in batch/vectorized mode; the builder tracks an isBatchReader flag and throws UnsupportedOperationException when batch reading was not requested. It is thrown immediately, before any rows are read, so no scan is started with an incompatible mode.","triggerScenarios":"Calling ORC.reads(...).project(schema).recordsPerBatch(n) (e.g. via .recordsPerBatch() on the ReadBuilder) without first calling .createReaderFunc(...)/selecting a batch reader (ORC.read(...).createBatchedReaderFunc). Any code path that requests batched reads on a reader built with the non-vectorized row factory.","commonSituations":"Migrating code from row-based scans to vectorized batch reads by just adding recordsPerBatch; copying Spark-style batch APIs; forgetting that the ORC ReadBuilder needs createReaderFunc with a batch-producing reader for recordsPerBatch to be valid.","solutions":["Configure a batch reader on the ReadBuilder (e.g. .createBatchedReaderFunc(...) / use the vectorized reader factory) before calling recordsPerBatch.","If batch semantics are not needed, drop the recordsPerBatch call and consume the row iterator instead.","Check the reader configuration/API version you are using; ensure the ORC format model supports batch reading for your table's schema (e.g. no unsupported types forcing the non-vectorized fallback)."],"exampleFix":"// before\nCloseableIterable<Record> rows = ORC.read(file)\n    .project(schema)\n    .recordsPerBatch(1024)  // UnsupportedOperationException\n    .build();\n\n// after\nORC.ReadBuilder<ColumnarBatch> batches = ORC.read(file)\n    .project(schema)\n    .createBatchedReaderFunc((type, batch) -> new MyOrcBatchReader(type, batch))\n    .recordsPerBatch(1024);","handlingStrategy":"validation","validationCode":"// ensure a batch reader is configured before requesting batches\nif (!readBuilderUsesBatchedReader) {\n  throw new IllegalStateException(\"recordsPerBatch requires a vectorized/batch reader\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair recordsPerBatch with createBatchedReaderFunc/vectorized reader setup","Do not copy batch-read APIs across engines without checking the ORC ReadBuilder contract","Read the ReadBuilder docs: batch mode is opt-in for ORC"],"tags":["java","orc","vectorized-reader","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}