apache/iceberg · error · UnsupportedOperationException
ORC cannot read default value for field
Error message
ORC cannot read default value for field %s (%s): %s
What it means
During buildOrcProjection, an Iceberg field missing from the ORC file is handled by writing a column filled with the field's default value. ORC's VectorizedRowBatch machinery cannot materialize Iceberg initial-default values, so if the field declares a non-null initialDefault an UnsupportedOperationException with the field name, type, and default is thrown. The error occurs at read planning time, not mid-scan of data.
Solutions
- Add the column without an initialDefault (or use write-default only), then rewrite data files so old files contain the column.
- Rewrite old ORC data files (e.g. rewrite_data_files / Spark rewrite) so the added column physically exists and no default back-fill is needed.
- Drop the requirement/default for the field, or use a file format whose reader supports initial-default materialization (Parquet).
Example fix
// before ALTER TABLE t ADD COLUMN status STRING NOT NULL WITH default 'new'; // old ORC files: UnsupportedOperationException // after ALTER TABLE t ADD COLUMN status STRING; -- nullable, no initialDefault -- then backfill data via rewrite/update instead of relying on reader-side defaults
Defensive patterns
Strategy: try-catch
Validate before calling
// detect problematic evolved fields before scanning
Types.NestedField f = schema.findField(fieldId);
if (f != null && f.isOptional() == false && f.initialDefault() != null && !fileContainsColumn) {
throw new UnsupportedOperationException("Rewrite files before scan: " + f.name());
} Try / catch
try {
CloseableIterable<Record> rows = read.build();
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("ORC cannot read default value")) {
// trigger rewrite_data_files or fall back to Parquet path
}
} Prevention
- Avoid adding required columns with initialDefault on ORC tables; use nullable columns plus backfill
- Run rewrite_data_files after schema evolution so old files contain new columns
- Parquet handles reader-side defaults; prefer it when default-value evolution is required
When it happens
Trigger: Reading (projection building for) an ORC data file whose schema predates an Iceberg schema evolution that ADDED a required field with an initialDefault; the missing field must be back-filled and its initialDefault() is non-null.
Common situations: Schema evolution: ALTER TABLE ADD COLUMN with a default value on an ORC table, then scanning old ORC files written before the column existed; ORC format does not support default-value materialization the way Parquet readers do.
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
- Batch reading is not supported in non-vectorized reader
- Can't get Stripe's length from the file writer with path
- Failed to get ORC rows for file
- Failed to get statistics from writer
- Failed to get stripe information from writer for
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/0be69cf3358459fa.
Report an issue: GitHub.
Appendix: source
Thrown at orc/src/main/java/org/apache/iceberg/orc/ORCSchemaUtil.java:408
Preconditions.checkArgument(
isSameType(originalType, type),
"Can not promote %s type to %s",
originalType.getCategory(),
type.typeId().name());
orcType = originalType.clone();
}
} else {
Types.NestedField field = root.findField(fieldId);
if (isRequired) {
Preconditions.checkArgument(
field.initialDefault() != null,
"Missing required field: %s (%s)",
root.findColumnName(fieldId),
type);
}
if (field.initialDefault() != null) {
throw new UnsupportedOperationException(
String.format(
"ORC cannot read default value for field %s (%s): %s",
root.findColumnName(fieldId), type, field.initialDefault()));
}
orcType = convert(fieldId, type, false);
}
}
if (orcType != null) {
orcType.setAttribute(ICEBERG_ID_ATTRIBUTE, fieldId.toString());
}
return orcType;
}
private static Map<Integer, OrcField> icebergToOrcMapping(String name, TypeDescription orcType) {
Map<Integer, OrcField> icebergToOrc = Maps.newHashMap();View on GitHub (pinned to 86d9c8fc54)