apache/iceberg · error · IllegalArgumentException
Invalid precision: ${precision}
Error message
Invalid precision: ${precision} What it means
FlinkOrcReaders.decimals selects a decimal reader by precision: <=18 uses a long-backed reader, <=38 a byte-array-backed reader. Any precision above 38 is impossible under Iceberg's decimal spec and throws IllegalArgumentException 'Invalid precision'.
Source
Thrown at flink/v1.20/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 schema so decimal precision is between 1 and 38
- Validate decimal precision at schema creation with TypeUtil/Preconditions before reading/writing
- Re-check the file's embedded schema validity if it comes from a foreign writer
Example fix
// before Types.DecimalType.of(45, 5) -> decimals() throws // after Types.DecimalType.of(38, 5)
Defensive patterns
Strategy: validation
Validate before calling
Preconditions.checkArgument(precision >= 1 && precision <= 38, "decimal precision must be 1..38, got %s", precision);
Type guard
boolean validDecimal(int p) { return p >= 1 && p <= 38; } Try / catch
try { reader = FlinkOrcReaders.decimals(p, s); } catch (IllegalArgumentException e) { /* fix schema */ throw e; } Prevention
- Validate decimals with TypeUtil at schema creation
- Reject precision > 38 early in ingestion pipelines
When it happens
Trigger: FlinkOrcReaders.decimals(precision, scale) called with precision > 38, e.g. from FlinkOrcReader when a schema declares a decimal beyond ORC/Iceberg limits.
Common situations: Hand-built schemas with decimal(40,x); corrupted or externally produced schema metadata with out-of-spec decimals.
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: %s
- Invalid precision: %s
- Invalid precision:
- Invalid precision:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/0db92920213bcd73.
Report an issue: GitHub.