{"record":{"id":"0b2395c23ac7b7d1","repo":"apache/iceberg","slug":"cannot-read-data-task-0b2395","errorCode":null,"errorMessage":"Cannot read data task.","messagePattern":"Cannot read data task\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/source/RowDataFileScanTaskReader.java","lineNumber":105,"sourceCode":"      RowDataProjection rowDataProjection =\n          RowDataProjection.create(\n              deletes.requiredRowType(),\n              deletes.requiredSchema().asStruct(),\n              projectedSchema.asStruct());\n      iterable = CloseableIterable.transform(iterable, rowDataProjection::wrap);\n    }\n\n    return iterable.iterator();\n  }\n\n  private CloseableIterable<RowData> newIterable(\n      FileScanTask task,\n      Schema schema,\n      Map<Integer, ?> idToConstant,\n      InputFilesDecryptor inputFilesDecryptor) {\n    CloseableIterable<RowData> iter;\n    if (task.isDataTask()) {\n      throw new UnsupportedOperationException(\"Cannot read data task.\");\n    } else {\n      ReadBuilder<RowData, RowType> builder =\n          FormatModelRegistry.readBuilder(\n              task.file().format(), RowData.class, inputFilesDecryptor.getInputFile(task));\n\n      if (nameMapping != null) {\n        builder.withNameMapping(NameMappingParser.fromJson(nameMapping));\n      }\n\n      iter =\n          builder\n              .project(schema)\n              .idToConstant(idToConstant)\n              .split(task.start(), task.length())\n              .caseSensitive(caseSensitive)\n              .filter(task.residual())\n              .reuseContainers()\n              .build();","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/source/RowDataFileScanTaskReader.java#L87-L123","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use the task-based reader (RowDataTaskReaderFactory / table.newScan().asOfTask(...)) that dispatches data tasks to the right reader.","Ensure you read tasks from TableScan#tasks() and route via Flink's task reader factory rather than instantiating RowDataFileScanTaskReader for every task.","Upgrade Iceberg/Flink integration version where data-task routing is handled generically.","If you own the reader selection, check task.isDataTask() and delegate to a compatible reader before calling this one."],"exampleFix":"// before\nRowDataFileScanTaskReader reader = new RowDataFileScanTaskReader(schema, nameMapping, caseSensitive);\nCloseableIterable<RowData> it = reader.open(task, idToConstant, decryptor); // throws if data task\n// after\nif (task.isDataTask()) {\n  it = dataTaskReaderFactory.create(task).open(task, idToConstant, decryptor);\n} else {\n  it = reader.open(task, idToConstant, decryptor);\n}","handlingStrategy":"validation","validationCode":"if (task.isDataTask()) {\n  throw new IllegalArgumentException(\"Route data tasks to a data-task reader, not RowDataFileScanTaskReader\");\n}","typeGuard":"boolean isDataTask(FileScanTask task) { return task.isDataTask(); }","tryCatchPattern":null,"preventionTips":["Always obtain readers via Iceberg's task reader factory instead of instantiating readers directly.","Check task.isDataTask() before selecting a reader implementation.","Keep reader selection logic in one place when customizing the Flink source."],"tags":["flink","reader","unsupported-operation","delete-files"],"backgroundTag":"unsupported-operation","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"}