apache/iceberg · error · IllegalArgumentException
Invalid precision: ${precision}
Error message
Invalid precision: ${precision} What it means
FlinkOrcWriters.decimals selects a decimal writer by precision: <=18 long-backed, <=38 byte-backed. Precision > 38 is invalid 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/FlinkOrcWriters.java:87
static OrcValueWriter<TimestampData> timestampTzs() {
return TimestampTzWriter.INSTANCE;
}
static OrcValueWriter<TimestampData> timestampNanos() {
return TimestampNanoWriter.INSTANCE;
}
static OrcValueWriter<TimestampData> timestampNanoTzs() {
return TimestampNanoTzWriter.INSTANCE;
}
static OrcValueWriter<DecimalData> decimals(int precision, int scale) {
if (precision <= 18) {
return new Decimal18Writer(precision, scale);
} else if (precision <= 38) {
return new Decimal38Writer(precision, scale);
} else {
throw new IllegalArgumentException("Invalid precision: " + precision);
}
}
static <T> OrcValueWriter<ArrayData> list(
OrcValueWriter<T> elementWriter, LogicalType elementType) {
return new ListWriter<>(elementWriter, elementType);
}
static <K, V> OrcValueWriter<MapData> map(
OrcValueWriter<K> keyWriter,
OrcValueWriter<V> valueWriter,
LogicalType keyType,
LogicalType valueType) {
return new MapWriter<>(keyWriter, valueWriter, keyType, valueType);
}
static OrcValueWriter<RowData> struct(List<OrcValueWriter<?>> writers, List<LogicalType> types) {
int[] fieldIndexes = new int[writers.size()];View on GitHub (pinned to 86d9c8fc54)
Solutions
- Correct the schema so decimal precision is <= 38
- Validate decimal types (TypeUtil) before committing the schema or starting the write
- Rewrite table metadata if it contains an invalid decimal definition
Example fix
// before DecimalType(50, 10) -> decimals() throws // after DecimalType(38, 10)
Defensive patterns
Strategy: validation
Validate before calling
if (precision < 1 || precision > 38) throw new IllegalArgumentException("decimal precision must be 1..38"); Type guard
boolean validDecimal(int p) { return p >= 1 && p <= 38; } Try / catch
try { writer = FlinkOrcWriters.decimals(p, s); } catch (IllegalArgumentException e) { /* fix schema */ throw e; } Prevention
- Validate decimal precision before writing
- Use TypeUtil validation in schema-building code
When it happens
Trigger: FlinkOrcWriters.decimals(precision, scale) invoked with precision > 38, typically from FlinkOrcWriter for an out-of-spec decimal column.
Common situations: Out-of-spec schemas from external tools or manual schema construction; corrupted metadata claiming a huge precision.
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/018c2680e2ce5ea8.
Report an issue: GitHub.