apache/iceberg · error · java.lang.IllegalArgumentException
Invalid precision: %s
Error message
Invalid precision: %s
What it means
FlinkOrcReaders.decimals() throws IllegalArgumentException 'Invalid precision: <p>' when a DECIMAL column's precision is greater than 38, because the reader only supports precision <= 18 (long-backed) and <= 38 (BigDecimal-backed). Iceberg itself caps decimal precision at 38, so this usually indicates corrupt/foreign metadata.
Source
Thrown at flink/v2.1/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 <= 38 (Iceberg max).
- Rewrite the ORC files with a supported precision (e.g. decimal(38, s)).
- Validate the table schema with TypeUtil/validation before scanning.
Example fix
// before Types.DecimalType.of(50, 5) // after Types.DecimalType.of(38, 5)
Defensive patterns
Strategy: validation
Validate before calling
Types.DecimalType dt = (Types.DecimalType) fieldType;
Preconditions.checkArgument(dt.precision() <= 38,
"ORC reader supports decimal precision <= 38, got %s", dt.precision()); Type guard
boolean readableDecimal(Types.DecimalType t) {
return t.precision() <= 38;
} Try / catch
try {
reader.read(row, ordinal);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Invalid precision")) {
// schema is outside Iceberg limits; fail fast with clear context
throw new IllegalStateException("Decimal precision beyond Iceberg limit: " + e.getMessage());
}
throw e;
} Prevention
- Cap decimal precision at 38 when defining schemas.
- Validate user-supplied DDL precision/scale before creating tables.
When it happens
Trigger: Reading ORC decimal columns whose declared precision exceeds 38, e.g. decimal(50, 5).
Common situations: ORC files produced by external systems allowing larger precisions; hand-built schemas with invalid precision; metadata corruption.
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: %s
- Invalid precision: ${precision}
- Invalid precision: ${precision}
- Invalid precision:
- Invalid precision:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/dfacf157c4940523.
Report an issue: GitHub.