apache/iceberg · error · UnsupportedOperationException

Cannot read data task.

Error message

Cannot read data task.

What it means

RowDataFileScanTaskReader.newIterable rejects FileScanTasks where task.isDataTask() is true, because position/equality-delete data tasks cannot be read through the RowData file reader path. This is an explicit UnsupportedOperationException: data tasks are internal planning artifacts, not readable files.

Solutions

  1. Filter out tasks where task.isDataTask() before passing them to the reader
  2. Use the appropriate reader/scan API for data tasks instead of RowDataFileScanTaskReader
  3. Regenerate tasks via table.newScan().planTasks() rather than constructing them manually
  4. If seen in stock Flink reads, report — it indicates a bug in task generation, and check the Iceberg version for known fixes

Example fix

// before
iter = reader.open(task, schema, idToConstant, decryptor); // throws for data tasks
// after
if (task.isDataTask()) {
  continue; // or handle via DataTask reader
}
iter = reader.open(task, schema, idToConstant, decryptor);
Defensive patterns

Strategy: type-guard

Validate before calling

if (task.isDataTask()) {
  throw new IllegalArgumentException("DataTask cannot be read by RowDataFileScanTaskReader");
}

Type guard

boolean readable = task != null && !task.isDataTask();

Try / catch

try {
  iter = reader.open(task, schema, idToConstant, decryptor);
} catch (UnsupportedOperationException e) {
  // data task encountered — route to DataTask reader or skip
  iter = CloseableIterable.empty();
}

Prevention

When it happens

Trigger: Feeding a CombinedScanTask containing DataFileScanTask/DataTask instances (e.g. from a scan that includes delete-file residual planning or custom tasks) into RowDataFileScanTaskReader, typically when mixing task types from custom scan logic or upgrading task representations.

Common situations: Custom source implementations that build tasks manually, reading tasks produced by remove-orphan/rewrite tooling, or mixing Data tasks from incremental scans into a file-reading iterator.

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/be709b4432948a74. Report an issue: GitHub.

Appendix: source

Thrown at flink/v1.20/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)