{"record":{"id":"16ca0d7f0a25b9f9","repo":"apache/iceberg","slug":"invalid-precision-s-16ca0d","errorCode":null,"errorMessage":"Invalid precision: %s","messagePattern":"Invalid precision: (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcWriters.java","lineNumber":87,"sourceCode":"  static OrcValueWriter<TimestampData> timestampTzs() {\n    return TimestampTzWriter.INSTANCE;\n  }\n\n  static OrcValueWriter<TimestampData> timestampNanos() {\n    return TimestampNanoWriter.INSTANCE;\n  }\n\n  static OrcValueWriter<TimestampData> timestampNanoTzs() {\n    return TimestampNanoTzWriter.INSTANCE;\n  }\n\n  static OrcValueWriter<DecimalData> decimals(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  static <T> OrcValueWriter<ArrayData> list(\n      OrcValueWriter<T> elementWriter, LogicalType elementType) {\n    return new ListWriter<>(elementWriter, elementType);\n  }\n\n  static <K, V> OrcValueWriter<MapData> map(\n      OrcValueWriter<K> keyWriter,\n      OrcValueWriter<V> valueWriter,\n      LogicalType keyType,\n      LogicalType valueType) {\n    return new MapWriter<>(keyWriter, valueWriter, keyType, valueType);\n  }\n\n  static OrcValueWriter<RowData> struct(List<OrcValueWriter<?>> writers, List<LogicalType> types) {\n    int[] fieldIndexes = new int[writers.size()];","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcWriters.java#L69-L105","documentation":"FlinkOrcWriters.decimals() throws IllegalArgumentException 'Invalid precision: <p>' when writing an ORC decimal with precision > 38; only precision <= 18 and <= 38 writers exist, matching Iceberg's decimal limit.","triggerScenarios":"Writing ORC data for a DECIMAL column with declared precision above 38 (e.g. decimal(40, 2)).","commonSituations":"Schemas created programmatically with invalid precision; data from external engines allowing wider decimals.","solutions":["Reduce the column precision to <= 38 in the schema.","Validate decimal precision before writing (Precision/scale <= 38).","Convert the column to string/bytes if wider precision must be preserved."],"exampleFix":"// before\nTypes.DecimalType.of(40, 2)\n// after\nTypes.DecimalType.of(38, 2)","handlingStrategy":"validation","validationCode":"Types.DecimalType dt = (Types.DecimalType) fieldType;\nPreconditions.checkArgument(dt.precision() <= 38,\n    \"ORC writer supports decimal precision <= 38, got %s\", dt.precision());","typeGuard":"boolean writableDecimal(Types.DecimalType t) {\n  return t.precision() <= 38;\n}","tryCatchPattern":"try {\n  writer.write(decimalData, ordinal);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Invalid precision\")) {\n    throw new IllegalStateException(\"Cannot write decimal with precision > 38: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Limit decimal precision to 38 in upstream pipelines.","Validate schema precision/scale at table creation time."],"tags":["flink","orc","decimal","precision"],"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-14T11:17:12.474Z"}