apache/iceberg · error · IllegalArgumentException
Invalid precision:
Error message
Invalid precision:
What it means
FlinkOrcReaders.decimals() builds ORC decimal readers and only supports precision up to 38: values <= 18 use Decimal18Reader (long-backed), values 19-38 use Decimal38Reader. Any precision above 38 cannot be represented by ORC decimal readers and throws IllegalArgumentException. This guards against reading ORC columns whose declared precision exceeds what Iceberg's Flink ORC integration handles.
Source
Thrown at flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcReaders.java:69
class FlinkOrcReaders {
private FlinkOrcReaders() {}
static OrcValueReader<StringData> strings() {
return StringReader.INSTANCE;
}
static OrcValueReader<Integer> dates() {
return DateReader.INSTANCE;
}
static OrcValueReader<DecimalData> decimals(int precision, int scale) {
if (precision <= 18) {
return new Decimal18Reader(precision, scale);
} else if (precision <= 38) {
return new Decimal38Reader(precision, scale);
} else {
throw new IllegalArgumentException("Invalid precision: " + precision);
}
}
static OrcValueReader<Integer> times() {
return TimeReader.INSTANCE;
}
static OrcValueReader<TimestampData> timestamps() {
return TimestampReader.INSTANCE;
}
static OrcValueReader<TimestampData> timestampTzs() {
return TimestampTzReader.INSTANCE;
}
static <T> OrcValueReader<ArrayData> array(OrcValueReader<T> elementReader) {
return new ArrayReader<>(elementReader);
}View on GitHub (pinned to 86d9c8fc54)
Solutions
- Fix the Iceberg/Flink schema so the column precision is <= 38 (and preferably <= 18 for the faster long-backed reader)
- Re-create/rewrite the table column with a valid precision, e.g. DECIMAL(38,scale) as the maximum
- If the source ORC file truly has precision > 38, re-write the data before reading it through this reader
Example fix
// before OrcValueReader<DecimalData> r = FlinkOrcReaders.decimals(42, 5); // throws // after OrcValueReader<DecimalData> r = FlinkOrcReaders.decimals(38, 5);
Defensive patterns
Strategy: validation
Validate before calling
if (precision > 38 || precision <= 0) {
throw new IllegalArgumentException("Decimal precision must be in (0, 38], got: " + precision);
}
OrcValueReader<DecimalData> reader = FlinkOrcReaders.decimals(precision, scale); Try / catch
try {
reader = FlinkOrcReaders.decimals(precision, scale);
} catch (IllegalArgumentException e) {
logger.error("Unsupported decimal precision: {}", precision, e);
throw new SchemaException("Column precision not supported for ORC read", e);
} Prevention
- Cap decimal precision at 38 (Iceberg spec max) at schema-design time
- Prefer precision <= 18 for the faster long-backed reader
- Validate precision before building readers in generic schema-mapping code
When it happens
Trigger: Calling FlinkOrcReaders.decimals(precision, scale) with precision > 38, typically from an ORC read schema built from an Iceberg DecimalType with precision > 38.
Common situations: A table column was created with an out-of-spec precision (Iceberg itself caps decimal precision at 38), or custom code constructs readers manually with an invalid precision, or a type mapping from another engine (e.g. Flink DECIMAL(42,5)) is passed through.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Invalid precision: ${precision}
- Invalid precision: ${precision}
- Invalid precision: %s
- Invalid precision: %s
- Invalid precision:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/a80fe4949c6089d2.
Report an issue: GitHub.