apache/iceberg · error · UnsupportedOperationException

Cannot read data task.

Error message

Cannot read data task.

What it means

RowDataFileScanTaskReader.newIterable builds the RowData reader for one FileScanTask. If the task is a data task (task.isDataTask(), i.e., a position/equality-delete-less raw data task used by certain delete-file rewrite paths), this reader cannot handle it and throws UnsupportedOperationException. Data tasks require a different reader path (e.g., RowDataDeletesFileScanTaskReader or generic task readers).

Source

Thrown at flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/source/RowDataFileScanTaskReader.java:105

      RowDataProjection rowDataProjection =
          RowDataProjection.create(
              deletes.requiredRowType(),
              deletes.requiredSchema().asStruct(),
              projectedSchema.asStruct());
      iterable = CloseableIterable.transform(iterable, rowDataProjection::wrap);
    }

    return iterable.iterator();
  }

  private CloseableIterable<RowData> newIterable(
      FileScanTask task,
      Schema schema,
      Map<Integer, ?> idToConstant,
      InputFilesDecryptor inputFilesDecryptor) {
    CloseableIterable<RowData> iter;
    if (task.isDataTask()) {
      throw new UnsupportedOperationException("Cannot read data task.");
    } else {
      ReadBuilder<RowData, RowType> builder =
          FormatModelRegistry.readBuilder(
              task.file().format(), RowData.class, inputFilesDecryptor.getInputFile(task));

      if (nameMapping != null) {
        builder.withNameMapping(NameMappingParser.fromJson(nameMapping));
      }

      iter =
          builder
              .project(schema)
              .idToConstant(idToConstant)
              .split(task.start(), task.length())
              .caseSensitive(caseSensitive)
              .filter(task.residual())
              .reuseContainers()
              .build();

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Use the task-based reader (RowDataTaskReaderFactory / table.newScan().asOfTask(...)) that dispatches data tasks to the right reader.
  2. Ensure you read tasks from TableScan#tasks() and route via Flink's task reader factory rather than instantiating RowDataFileScanTaskReader for every task.
  3. Upgrade Iceberg/Flink integration version where data-task routing is handled generically.
  4. If you own the reader selection, check task.isDataTask() and delegate to a compatible reader before calling this one.

Example fix

// before
RowDataFileScanTaskReader reader = new RowDataFileScanTaskReader(schema, nameMapping, caseSensitive);
CloseableIterable<RowData> it = reader.open(task, idToConstant, decryptor); // throws if data task
// after
if (task.isDataTask()) {
  it = dataTaskReaderFactory.create(task).open(task, idToConstant, decryptor);
} else {
  it = reader.open(task, idToConstant, decryptor);
}
Defensive patterns

Strategy: validation

Validate before calling

if (task.isDataTask()) {
  throw new IllegalArgumentException("Route data tasks to a data-task reader, not RowDataFileScanTaskReader");
}

Type guard

boolean isDataTask(FileScanTask task) { return task.isDataTask(); }

Prevention

When it happens

Trigger: Using RowDataFileScanTaskReader over scan tasks containing data tasks — e.g., scans produced from tables whose delete handling yields HybridSplitTask/data tasks, or wiring this reader manually into a custom Flink source instead of using tasks() from the table scan.

Common situations: Custom Flink readers built on older Iceberg task APIs reading tables rewritten with delete files (v2 tables); mixing reader implementations when migrating Flink code between Iceberg versions.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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