{"record":{"id":"762003c9518b1e57","repo":"apache/iceberg","slug":"cannot-parse-type-string-to-primitive-typestrin","errorCode":null,"errorMessage":"Cannot parse type string to primitive: + typeString","messagePattern":"Cannot parse type string to primitive: \\+ typeString","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/types/Types.java","lineNumber":106,"sourceCode":"    if (geography.matches()) {\n      String crs = geography.group(1);\n      String algorithmName = geography.group(2);\n      EdgeAlgorithm algorithm =\n          algorithmName == null ? null : EdgeAlgorithm.fromName(algorithmName);\n      return GeographyType.of(crs, algorithm);\n    }\n\n    Matcher fixed = FIXED.matcher(lowerTypeString);\n    if (fixed.matches()) {\n      return FixedType.ofLength(Integer.parseInt(fixed.group(1)));\n    }\n\n    Matcher decimal = DECIMAL.matcher(lowerTypeString);\n    if (decimal.matches()) {\n      return DecimalType.of(Integer.parseInt(decimal.group(1)), Integer.parseInt(decimal.group(2)));\n    }\n\n    throw new IllegalArgumentException(\"Cannot parse type string to primitive: \" + typeString);\n  }\n\n  public static PrimitiveType fromPrimitiveString(String typeString) {\n    Type type = fromTypeName(typeString);\n    if (type.isPrimitiveType()) {\n      return type.asPrimitiveType();\n    }\n\n    throw new IllegalArgumentException(\"Cannot parse type string: variant is not a primitive type\");\n  }\n\n  public static class BooleanType extends PrimitiveType {\n    private static final BooleanType INSTANCE = new BooleanType();\n\n    public static BooleanType get() {\n      return INSTANCE;\n    }\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/types/Types.java#L88-L124","documentation":"Thrown by Types.fromTypeName when a type string does not match any known Iceberg type name or pattern (simple types like 'long', parameterized 'decimal(p,s)', 'fixed(n)', 'geometry(crs)', 'geography(crs,alg)'). The string failed the TYPES map lookup and all regex matchers, so it cannot be parsed into a Type.","triggerScenarios":"Calling Types.fromTypeName (directly or via fromPrimitiveString/type) with a string like 'Decimal(38,10)' without lowercase-normalizable spelling, 'decimal(38)' (missing scale), 'varchar(20)', or any misspelled/unregistered type name.","commonSituations":"Schema definitions parsed from user config, DDL translation from other systems (e.g. passing Spark's 'string' fine, but 'int64', 'text', or 'numeric' are not Iceberg names), typos in type strings in table properties or SQL catalogs.","solutions":["Use exact Iceberg type names: boolean, int, long, float, double, decimal(p,s), date, time, timestamp, timestamptz, string, uuid, fixed(n), binary, geometry, geography, variant","For decimals include both precision and scale: decimal(38,10) not decimal(38)","Translate engine-specific type names to Iceberg names before calling (e.g. numeric -> decimal)","Trim whitespace and verify spelling; the string is matched case-insensitively but must otherwise be exact"],"exampleFix":"// before\nType t = Types.fromTypeName(\"numeric(38,10)\");\n// after\nType t = Types.fromTypeName(\"decimal(38,10)\");","handlingStrategy":"try-catch","validationCode":"// check type string against known Iceberg type names before parsing\nboolean known = java.util.Set.of(\"boolean\",\"int\",\"long\",\"float\",\"double\",\"date\",\"time\",\"timestamp\",\"timestamptz\",\"string\",\"uuid\",\"binary\",\"variant\").contains(typeString.toLowerCase(Locale.ROOT))\n    || typeString.toLowerCase(Locale.ROOT).matches(\"decimal\\\\(\\\\s*\\\\d+\\\\s*,\\\\s*\\\\d+\\\\s*\\\\)\")\n    || typeString.toLowerCase(Locale.ROOT).matches(\"fixed\\\\(\\\\s*\\\\d+\\\\s*\\\\)\");","typeGuard":"boolean isParsableIcebergType(String s) {\n  try { Types.fromTypeName(s); return true; } catch (IllegalArgumentException e) { return false; }\n}","tryCatchPattern":"try {\n  Type type = Types.fromTypeName(typeString);\n} catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Unknown Iceberg type string: \" + typeString, e);\n}","preventionTips":["Keep a canonical list of Iceberg type names in your schema-translation code","Translate engine type names (numeric, text, int64) to Iceberg names before parsing","Require decimal types to carry both precision and scale","Trim and lowercase-normalize user-supplied type strings (parser is case-insensitive but exact otherwise)"],"tags":["java","type-parsing","schema","invalid-input"],"backgroundTag":"invalid-argument-format","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"}