{"record":{"id":"31c2949f0dd91433","repo":"apache/iceberg","slug":"cannot-convert-unknown-primitive-type-s","errorCode":null,"errorMessage":"Cannot convert unknown primitive type: %s","messagePattern":"Cannot convert unknown primitive type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/parquet/MessageTypeToType.java","lineNumber":181,"sourceCode":"      case BOOLEAN:\n        return Types.BooleanType.get();\n      case INT32:\n        return Types.IntegerType.get();\n      case INT64:\n        return Types.LongType.get();\n      case FLOAT:\n        return Types.FloatType.get();\n      case DOUBLE:\n        return Types.DoubleType.get();\n      case FIXED_LEN_BYTE_ARRAY:\n        return Types.FixedType.ofLength(primitive.getTypeLength());\n      case INT96:\n        return Types.TimestampType.withZone();\n      case BINARY:\n        return Types.BinaryType.get();\n    }\n\n    throw new UnsupportedOperationException(\"Cannot convert unknown primitive type: \" + primitive);\n  }\n\n  @Override\n  public Type variant(GroupType variant) {\n    return Types.VariantType.get();\n  }\n\n  private static class ParquetLogicalTypeVisitor\n      implements LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<Type> {\n    private static final ParquetLogicalTypeVisitor INSTANCE = new ParquetLogicalTypeVisitor();\n\n    private static ParquetLogicalTypeVisitor get() {\n      return INSTANCE;\n    }\n\n    @Override\n    public Optional<Type> visit(LogicalTypeAnnotation.StringLogicalTypeAnnotation stringType) {\n      return Optional.of(Types.StringType.get());","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/parquet/MessageTypeToType.java#L163-L199","documentation":"Thrown by MessageTypeToType.primitive when converting a Parquet MessageType primitive column into an Iceberg Type and the primitive name matches no known case. Indicates the Parquet schema contains a primitive this Iceberg version cannot map.","triggerScenarios":"Converting a Parquet schema (MessageType) to an Iceberg Type where the column's primitive falls through the switch, e.g. a type added in newer Parquet releases.","commonSituations":"Reading files produced by newer writers than the Iceberg version in use; INT96 or other edge types before mapping existed; incompatible library versions on the classpath.","solutions":["Upgrade Iceberg so the primitive type is mapped","Rewrite the data with supported Parquet primitive types","Inspect the offending column with parquet-tools and adjust the schema"],"exampleFix":"// before\n// reading file with newer parquet type using old iceberg\n// after\n// upgrade dependency\n// implementation 'org.apache.iceberg:iceberg-spark-runtime:latest'","handlingStrategy":"try-catch","validationCode":"MessageType parquetSchema = ParquetFileReader.readFooter(conf, path).getFileMetaData().getSchema();\nparquetSchema.getColumns().forEach(c -> {\n  if (!KNOWN_PRIMITIVES.contains(c.getPrimitiveTypeName())) throw new IllegalStateException(\"Unmappable type: \" + c.getPrimitiveTypeName());\n});","typeGuard":null,"tryCatchPattern":"try {\n  Type icebergType = new MessageTypeToType(parquetSchema).convert(field);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Cannot convert unknown primitive type\")) { /* upgrade iceberg */ }\n}","preventionTips":["Keep Iceberg up to date with the Parquet versions your writers emit","Audit external Parquet data sources before registering them as tables","Avoid mixed parquet-mr/iceberg library versions on the classpath"],"tags":["parquet","schema-conversion","unsupported-type"],"backgroundTag":"incompatible-source-type","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}