{"record":{"id":"c83759e334267b06","repo":"apache/iceberg","slug":"does-not-support-schema-getter","errorCode":null,"errorMessage":"Does not support schema getter","messagePattern":"Does not support schema getter","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/FileScanTask.java","lineNumber":35,"sourceCode":" * under the License.\n */\npackage org.apache.iceberg;\n\nimport java.util.List;\nimport org.apache.iceberg.util.ScanTaskUtil;\n\n/** A scan task over a range of bytes in a single data file. */\npublic interface FileScanTask extends ContentScanTask<DataFile>, SplittableScanTask<FileScanTask> {\n  /**\n   * A list of {@link DeleteFile delete files} to apply when reading the task's data file.\n   *\n   * @return a list of delete files to apply\n   */\n  List<DeleteFile> deletes();\n\n  /** Return the schema for this file scan task. */\n  default Schema schema() {\n    throw new UnsupportedOperationException(\"Does not support schema getter\");\n  }\n\n  @Override\n  default long sizeBytes() {\n    return length() + ScanTaskUtil.contentSizeInBytes(deletes());\n  }\n\n  @Override\n  default int filesCount() {\n    return 1 + deletes().size();\n  }\n\n  @Override\n  default boolean isFileScanTask() {\n    return true;\n  }\n\n  @Override","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/FileScanTask.java#L17-L53","documentation":"FileScanTask.schema() is a default interface method that returns the schema used to read the task's data file. Most implementations do not carry a schema, so the default throws UnsupportedOperationException; callers must handle implementations that cannot supply one.","triggerScenarios":"Calling schema() on a FileScanTask produced by an implementation that does not override it, e.g. generic task serialization (toJson) or test assertion helpers (assertFileScanTaskEquals) running against basic scan tasks.","commonSituations":"Custom metadata/logic that serializes scan tasks from engines whose tasks don't embed schemas; unit-test comparison utilities applied to tasks from sources lacking schema support.","solutions":["Only call schema() on tasks known to support it (check instanceof or a capability flag), otherwise use the table's current schema","For serialization, skip or omit the schema field when UnsupportedOperationException is thrown","If you own the FileScanTask implementation, override schema() to return the read schema"],"exampleFix":"// before\nSchema schema = task.schema();\n// after\nSchema schema;\ntry {\n  schema = task.schema();\n} catch (UnsupportedOperationException e) {\n  schema = table.schema();\n}","handlingStrategy":"try-catch","validationCode":"boolean hasSchema = task.getClass().getName().contains(\"SchemaAware\"); // or capability check","typeGuard":"boolean supportsSchema(FileScanTask t) {\n  try { t.schema(); return true; } catch (UnsupportedOperationException e) { return false; }\n}","tryCatchPattern":"try {\n  schema = task.schema();\n} catch (UnsupportedOperationException e) {\n  schema = table.schema();\n}","preventionTips":["Default to table.schema() unless the task is known schema-aware","Wrap schema() in a helper with a fallback","Don't assume all FileScanTask implementations carry a schema"],"tags":["java","scantask","unsupported-operation"],"backgroundTag":"method-not-implemented","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}