{"record":{"id":"018c2680e2ce5ea8","repo":"apache/iceberg","slug":"invalid-precision-precision-018c26","errorCode":null,"errorMessage":"Invalid precision: ${precision}","messagePattern":"Invalid precision: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/data/FlinkOrcWriters.java#L69-L105","documentation":"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'.","triggerScenarios":"FlinkOrcWriters.decimals(precision, scale) invoked with precision > 38, typically from FlinkOrcWriter for an out-of-spec decimal column.","commonSituations":"Out-of-spec schemas from external tools or manual schema construction; corrupted metadata claiming a huge precision.","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"],"exampleFix":"// before\nDecimalType(50, 10) -> decimals() throws\n// after\nDecimalType(38, 10)","handlingStrategy":"validation","validationCode":"if (precision < 1 || precision > 38) throw new IllegalArgumentException(\"decimal precision must be 1..38\");","typeGuard":"boolean validDecimal(int p) { return p >= 1 && p <= 38; }","tryCatchPattern":"try { writer = FlinkOrcWriters.decimals(p, s); } catch (IllegalArgumentException e) { /* fix schema */ throw e; }","preventionTips":["Validate decimal precision before writing","Use TypeUtil validation in schema-building code"],"tags":["flink","orc","decimal","validation"],"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"}