apache/iceberg · error · java.lang.IllegalArgumentException

Invalid precision:

Error message

Invalid precision: 

What it means

FlinkOrcWriters.decimals() selects an ORC decimal writer based on precision: Decimal18Writer for precision <= 18 (fits in a long) and Decimal38Writer for precision <= 38. Any precision above 38 cannot be represented by Iceberg's decimal model or ORC's decimal logical type, so the factory throws IllegalArgumentException immediately.

Source

Thrown at flink/v2.3/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

  1. Fix the source schema so the decimal precision is within 1..38 (Iceberg/ORC max).
  2. Re-create/evolve the table column with a valid precision, e.g. DECIMAL(38, scale), and migrate data.
  3. If precision comes from config or another catalog, validate/clamp it before constructing the writer and fail with a clear schema-validation error upstream.

Example fix

// before
Types.DecimalType.of(50, 10) // invalid
// after
Types.DecimalType.of(38, 10)
Defensive patterns

Strategy: validation

Validate before calling

// java
if (decimalType.precision() > 38 || decimalType.precision() < 1) {
  throw new IllegalArgumentException(
      "Decimal precision " + decimalType.precision() + " out of range [1,38]");
}

Prevention

When it happens

Trigger: Calling FlinkOrcWriters.decimals(precision, scale) with precision > 38 (or negative), typically while building an ORC appender from a Flink RowType/ Iceberg Types.DecimalType whose precision exceeds 38.

Common situations: A table schema was created with an out-of-spec decimal precision (e.g. DECIMAL(50, 10)); a schema evolution or external catalog registered an oversized precision; a buggy type-derivation path computed precision instead of failing earlier at schema validation.

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


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/3451c37d5552eea6. Report an issue: GitHub.