{"record":{"id":"1dd32afbc93e2fcf","repo":"apache/iceberg","slug":"invalid-precision-1dd32a","errorCode":null,"errorMessage":"Invalid precision: ","messagePattern":"Invalid precision: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcValueReaders.java","lineNumber":69,"sourceCode":"  public static OrcValueReader<UTF8String> utf8String() {\n    return StringReader.INSTANCE;\n  }\n\n  public static OrcValueReader<UTF8String> uuids() {\n    return UUIDReader.INSTANCE;\n  }\n\n  public static OrcValueReader<Long> timestampTzs() {\n    return TimestampTzReader.INSTANCE;\n  }\n\n  public static OrcValueReader<Decimal> decimals(int precision, int scale) {\n    if (precision <= Decimal.MAX_LONG_DIGITS()) {\n      return new SparkOrcValueReaders.Decimal18Reader(precision, scale);\n    } else if (precision <= 38) {\n      return new SparkOrcValueReaders.Decimal38Reader(precision, scale);\n    } else {\n      throw new IllegalArgumentException(\"Invalid precision: \" + precision);\n    }\n  }\n\n  static OrcValueReader<?> struct(\n      TypeDescription record,\n      List<OrcValueReader<?>> readers,\n      Types.StructType struct,\n      Map<Integer, ?> idToConstant) {\n    return new StructReader(record, readers, struct, idToConstant);\n  }\n\n  static OrcValueReader<?> array(OrcValueReader<?> elementReader) {\n    return new ArrayReader(elementReader);\n  }\n\n  static OrcValueReader<?> map(OrcValueReader<?> keyReader, OrcValueReader<?> valueReader) {\n    return new MapReader(keyReader, valueReader);\n  }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcValueReaders.java#L51-L87","documentation":"SparkOrcValueReaders.decimals creates ORC decimal readers by precision: up to MAX_LONG_DIGITS uses Decimal18Reader, up to 38 uses Decimal38Reader, and anything above 38 throws IllegalArgumentException('Invalid precision: ' + precision). Decimal precision beyond 38 is not representable in Iceberg/Spark.","triggerScenarios":"Registering/reading an ORC file whose schema declares a decimal with precision > 38, causing decimals(precision, scale) to reject it.","commonSituations":"ORC data written by external engines allowing wider decimals; schema conversion mapping ORC decimals with unsupported precision into an Iceberg read path; incorrect precision in hand-written schemas.","solutions":["Reduce the decimal precision to <= 38 in the source data or schema","Cast/convert oversized decimals to strings or scaled longs before Iceberg reads them","Fix the ORC schema if the precision is wrong (external writer misconfiguration)","Verify Iceberg's supported decimal range (precision 1-38) when defining table schemas"],"exampleFix":"// before\nTypeDescription schema = TypeDescription.createDecimal(42, 4);\n// after\nTypeDescription schema = TypeDescription.createDecimal(38, 4);","handlingStrategy":"validation","validationCode":"int precision = orcType.getPrecision();\nif (precision > 38) {\n  throw new IllegalArgumentException(\"Decimal precision \" + precision + \" exceeds Iceberg max of 38\");\n}","typeGuard":"boolean validDecimal(int precision) { return precision >= 1 && precision <= 38; }","tryCatchPattern":"try { OrcValueReader<?> r = SparkOrcValueReaders.decimals(precision, scale); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Invalid precision\")) { /* convert data */ } else { throw e; } }","preventionTips":["Cap decimal precision at 38 when writing ORC or defining table schemas","Convert wider decimals from external engines before Iceberg ingestion","Validate ORC schema precisions during ingestion checks"],"tags":["spark","orc","decimal","precision","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"}