{"record":{"id":"6a8dfbf856285ab5","repo":"apache/iceberg","slug":"invalid-precision-6a8dfb","errorCode":null,"errorMessage":"Invalid precision: ","messagePattern":"Invalid precision: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/data/orc/GenericOrcWriters.java","lineNumber":146,"sourceCode":"  public static OrcValueWriter<LocalDateTime> timestamp() {\n    return TimestampWriter.INSTANCE;\n  }\n\n  public static OrcValueWriter<OffsetDateTime> timestampTzNanos() {\n    return TimestampTzNanoWriter.INSTANCE;\n  }\n\n  public static OrcValueWriter<LocalDateTime> timestampNanos() {\n    return TimestampNanoWriter.INSTANCE;\n  }\n\n  public static OrcValueWriter<BigDecimal> decimal(int precision, int scale) {\n    if (precision <= 18) {\n      return new Decimal18Writer(precision, scale);\n    } else if (precision <= 38) {\n      return new Decimal38Writer(precision, scale);\n    } else {\n      throw new IllegalArgumentException(\"Invalid precision: \" + precision);\n    }\n  }\n\n  public static OrcValueWriter<Variant> variants() {\n    return VariantWriter.INSTANCE;\n  }\n\n  public static <T> OrcValueWriter<List<T>> list(OrcValueWriter<T> element) {\n    return new ListWriter<>(element);\n  }\n\n  public static <K, V> OrcValueWriter<Map<K, V>> map(\n      OrcValueWriter<K> key, OrcValueWriter<V> value) {\n    return new MapWriter<>(key, value);\n  }\n\n  public static <T> OrcRowWriter<PositionDelete<T>> positionDelete(\n      OrcRowWriter<T> writer, Function<CharSequence, ?> pathTransformFunc) {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/data/orc/GenericOrcWriters.java#L128-L164","documentation":"GenericOrcWriters.decimal(precision, scale) only supports BigDecimal precision up to 38 (18 -> long-backed writer, 38 -> second writer). A precision above 38 cannot be represented by the ORC decimal writers, so IllegalArgumentException(\"Invalid precision: N\") is thrown.","triggerScenarios":"Creating/writing an Iceberg ORC table whose decimal column declares precision > 38.","commonSituations":"Hand-written schemas with overly large decimal precision; DDL copied from other engines allowing bigger precision; misconfigured type conversion.","solutions":["Reduce the column precision to <= 38 in the table schema.","Use STRING (or DOUBLE) if you truly need more range/precision.","Validate schema precision before creating ORC tables.","Fix the DDL/source that generated the oversized decimal type."],"exampleFix":"// before\nTypes.DecimalType.of(50, 10) // precision 50 > 38 -> IllegalArgumentException\n// after\nTypes.DecimalType.of(38, 10) // max supported precision","handlingStrategy":"validation","validationCode":"// check precision before creating/writing\nTypes.DecimalType dt = (Types.DecimalType) type;\nif (dt.precision() > 38) throw new IllegalArgumentException(\"ORC decimal precision must be <= 38, got \" + dt.precision());","typeGuard":"boolean decimalSupported = t instanceof Types.DecimalType && ((Types.DecimalType) t).precision() <= 38;","tryCatchPattern":"try { write(...); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Invalid precision\")) { /* fix schema to precision<=38 */ } throw e; }","preventionTips":["Cap decimal precision at 38 in DDL","Use STRING for arbitrary-precision needs","Validate schemas at table creation","Copy precision limits from the engine's own constraints"],"tags":["orc","writer","decimal","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}