{"record":{"id":"be709b4432948a74","repo":"apache/iceberg","slug":"cannot-read-data-task","errorCode":null,"errorMessage":"Cannot read data task.","messagePattern":"Cannot read data task\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/source/RowDataFileScanTaskReader.java#L87-L123","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Filter out tasks where task.isDataTask() before passing them to the reader","Use the appropriate reader/scan API for data tasks instead of RowDataFileScanTaskReader","Regenerate tasks via table.newScan().planTasks() rather than constructing them manually","If seen in stock Flink reads, report — it indicates a bug in task generation, and check the Iceberg version for known fixes"],"exampleFix":"// before\niter = reader.open(task, schema, idToConstant, decryptor); // throws for data tasks\n// after\nif (task.isDataTask()) {\n  continue; // or handle via DataTask reader\n}\niter = reader.open(task, schema, idToConstant, decryptor);","handlingStrategy":"type-guard","validationCode":"if (task.isDataTask()) {\n  throw new IllegalArgumentException(\"DataTask cannot be read by RowDataFileScanTaskReader\");\n}","typeGuard":"boolean readable = task != null && !task.isDataTask();","tryCatchPattern":"try {\n  iter = reader.open(task, schema, idToConstant, decryptor);\n} catch (UnsupportedOperationException e) {\n  // data task encountered — route to DataTask reader or skip\n  iter = CloseableIterable.empty();\n}","preventionTips":["Only pass file-backed FileScanTasks from planTasks output","Filter data tasks before building read iterators","Regenerate tasks from table.newScan() rather than constructing manually"],"tags":["flink","source","unsupported-operation","data-task"],"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"}