{"record":{"id":"2b09389a8bafb1da","repo":"apache/iceberg","slug":"row-based-reads-are-not-supported-2b0938","errorCode":null,"errorMessage":"Row-based reads are not supported","messagePattern":"Row-based reads are not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkColumnarReaderFactory.java","lineNumber":47,"sourceCode":"import org.apache.spark.sql.vectorized.ColumnarBatch;\n\nclass SparkColumnarReaderFactory implements PartitionReaderFactory {\n  private final ParquetBatchReadConf parquetConf;\n  private final OrcBatchReadConf orcConf;\n\n  SparkColumnarReaderFactory(ParquetBatchReadConf conf) {\n    this.parquetConf = conf;\n    this.orcConf = null;\n  }\n\n  SparkColumnarReaderFactory(OrcBatchReadConf conf) {\n    this.orcConf = conf;\n    this.parquetConf = null;\n  }\n\n  @Override\n  public PartitionReader<InternalRow> createReader(InputPartition inputPartition) {\n    throw new UnsupportedOperationException(\"Row-based reads are not supported\");\n  }\n\n  @Override\n  public PartitionReader<ColumnarBatch> createColumnarReader(InputPartition inputPartition) {\n    Preconditions.checkArgument(\n        inputPartition instanceof SparkInputPartition,\n        \"Unknown input partition type: %s\",\n        inputPartition.getClass().getName());\n\n    SparkInputPartition partition = (SparkInputPartition) inputPartition;\n\n    if (partition.allTasksOfType(FileScanTask.class)) {\n      return new BatchDataReader(partition, parquetConf, orcConf);\n    } else {\n      throw new UnsupportedOperationException(\n          \"Unsupported task group for columnar reads: \" + partition.taskGroup());\n    }\n  }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkColumnarReaderFactory.java#L29-L65","documentation":"Capability guard in SparkColumnarReaderFactory.createReader: this factory serves only columnar (ColumnarBatch) reads, so the row-based PartitionReader creation entry point is unsupported and always throws. It fires when Spark requests row-based reading from a columnar-configured reader factory.","triggerScenarios":"Spark requests row-based reads from this reader factory, e.g. a data source option forcing non-columnar reads or Spark internals calling createReader instead of createColumnarReader.","commonSituations":"Combining this factory with configs like spark.sql.inMemoryColumnarStorage or reader selection logic that expects row-based readers; misuse of the factory outside the normal batch read path.","solutions":["Use createColumnarReader; ensure the read path supports columnar batches","Do not register this factory where row-based reads are required","Use the row-oriented reader factory (SparkBatchQueryScan row reader path) instead"],"exampleFix":"// before\nreaderFactory.createReader(partition);\n// after\nreaderFactory.createColumnarReader(partition);","handlingStrategy":"fallback","validationCode":"if (!readerFactory.supportsColumnar) { /* use row path */ }","typeGuard":null,"tryCatchPattern":"try { createReader(p); } catch (UnsupportedOperationException e) { reader = createColumnarReader(p); }","preventionTips":["Use the columnar read API with this factory","Check supportColumnarReads before selecting read mode"],"tags":["spark","iceberg","columnar","unsupported-feature"],"backgroundTag":"operation-not-supported","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}