{"record":{"id":"00b640a36c162846","repo":"apache/iceberg","slug":"invalid-precision-00b640","errorCode":null,"errorMessage":"Invalid precision: ","messagePattern":"Invalid precision: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/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/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcValueReaders.java#L51-L87","documentation":"SparkOrcValueReaders.decimals picks a Decimal18Reader (precision <= 18) or Decimal38Reader (precision <= 38) based on the decimal precision. Any precision above 38 is invalid for Iceberg/ORC decimals. This IllegalArgumentException reports a decimal precision that exceeds the 38-digit maximum.","triggerScenarios":"Reading ORC data whose schema declares a decimal with precision > 38, e.g. DECIMAL(50,10), during a Spark read through Iceberg.","commonSituations":"Tables created or written by systems that allow wider decimals than Iceberg's 38-digit limit; schema drift after importing external ORC data.","solutions":["Change the column to decimal(38, scale) or smaller precision.","Rewrite the external data with precision <= 38 before reading via Iceberg.","Cast/widen handling at the source engine before the data reaches Iceberg's reader."],"exampleFix":"// before\nALTER TABLE t ADD COLUMN d DECIMAL(50,10)\n// after\nALTER TABLE t ADD COLUMN d DECIMAL(38,10)","handlingStrategy":"validation","validationCode":"int precision = ((org.apache.iceberg.types.Types.DecimalType) type).precision();\nif (precision > 38) {\n  throw new IllegalArgumentException(\"decimal precision must be <= 38, got \" + precision);\n}","typeGuard":"static boolean isValidDecimal(org.apache.iceberg.types.Type t) {\n  if (t instanceof org.apache.iceberg.types.Types.DecimalType d) {\n    return d.precision() >= 1 && d.precision() <= 38 && d.scale() >= 0 && d.scale() <= d.precision();\n  }\n  return false;\n}","tryCatchPattern":null,"preventionTips":["Cap decimal precision at 38 in schemas","Validate external schemas before import","Downcast wide decimals at the source system"],"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"}