{"record":{"id":"ecd0e1bcde84041d","repo":"apache/iceberg","slug":"invalid-precision-ecd0e1","errorCode":null,"errorMessage":"Invalid precision: ","messagePattern":"Invalid precision: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/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.2/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcWriters.java#L69-L105","documentation":"FlinkOrcWriters.decimals() mirrors the reader: precision <= 18 yields Decimal18Writer, 19-38 yields Decimal38Writer, and anything above 38 throws IllegalArgumentException 'Invalid precision: <p>'. ORC decimal writers in Iceberg's Flink integration cannot represent precision beyond 38, so the library fails fast instead of writing corrupt data.","triggerScenarios":"Calling FlinkOrcWriters.decimals(precision, scale) with precision > 38, usually from FlinkOrcWriters when writing an Iceberg DecimalType column with out-of-range precision.","commonSituations":"Flink DECIMAL type with precision above 38 declared in a sink DDL, an Iceberg schema edited to an invalid precision, or generic code that forwards user-supplied precision without bounds checking.","solutions":["Reduce the column precision to <= 38 in the Iceberg schema and Flink DDL","Use DECIMAL(38, scale) as the maximum supported precision","Validate user-supplied precision before calling decimals()"],"exampleFix":"// before\n.writer(FlinkOrcWriters.decimals(40, 2)) // throws\n// after\n.writer(FlinkOrcWriters.decimals(38, 2))","handlingStrategy":"validation","validationCode":"Preconditions.checkArgument(precision >= 1 && precision <= 38,\n    \"Decimal precision must be within [1, 38], got: \" + precision);\nOrcValueWriter<DecimalData> w = FlinkOrcWriters.decimals(precision, scale);","typeGuard":null,"tryCatchPattern":"try {\n  writer = FlinkOrcWriters.decimals(precision, scale);\n} catch (IllegalArgumentException e) {\n  logger.error(\"Decimal precision {} out of range for ORC write\", precision, e);\n  throw e;\n}","preventionTips":["Validate DDL decimal precision before creating the sink","Use DECIMAL(38,scale) as max; DECIMAL(18,scale) for performance","Clamp or reject user-supplied precision in ETL config parsing"],"tags":["flink","orc","decimal"],"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"}