apache/iceberg · error · UnsupportedOperationException
Does not support schema getter
Error message
Does not support schema getter
What it means
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.
Source
Thrown at api/src/main/java/org/apache/iceberg/FileScanTask.java:35
* under the License.
*/
package org.apache.iceberg;
import java.util.List;
import org.apache.iceberg.util.ScanTaskUtil;
/** A scan task over a range of bytes in a single data file. */
public interface FileScanTask extends ContentScanTask<DataFile>, SplittableScanTask<FileScanTask> {
/**
* A list of {@link DeleteFile delete files} to apply when reading the task's data file.
*
* @return a list of delete files to apply
*/
List<DeleteFile> deletes();
/** Return the schema for this file scan task. */
default Schema schema() {
throw new UnsupportedOperationException("Does not support schema getter");
}
@Override
default long sizeBytes() {
return length() + ScanTaskUtil.contentSizeInBytes(deletes());
}
@Override
default int filesCount() {
return 1 + deletes().size();
}
@Override
default boolean isFileScanTask() {
return true;
}
@OverrideView on GitHub (pinned to 86d9c8fc54)
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
Example fix
// before
Schema schema = task.schema();
// after
Schema schema;
try {
schema = task.schema();
} catch (UnsupportedOperationException e) {
schema = table.schema();
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean hasSchema = task.getClass().getName().contains("SchemaAware"); // or capability check Type guard
boolean supportsSchema(FileScanTask t) {
try { t.schema(); return true; } catch (UnsupportedOperationException e) { return false; }
} Try / catch
try {
schema = task.schema();
} catch (UnsupportedOperationException e) {
schema = table.schema();
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Can't retrieve values from an empty struct
- Can't modify an empty struct
- %s doesn't implement cleanupLevel
- %s doesn't implement cleanExpiredMetadata
- %s does not implement deleteFile
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/c83759e334267b06.
Report an issue: GitHub.