{"record":{"id":"052dccf70b9c2446","repo":"apache/iceberg","slug":"unsupported-type-052dcc","errorCode":null,"errorMessage":"Unsupported type: ","messagePattern":"Unsupported type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/data/avro/DataWriter.java","lineNumber":165,"sourceCode":"          return ValueWriters.nulls();\n        case BOOLEAN:\n          return ValueWriters.booleans();\n        case INT:\n          return ValueWriters.ints();\n        case LONG:\n          return ValueWriters.longs();\n        case FLOAT:\n          return ValueWriters.floats();\n        case DOUBLE:\n          return ValueWriters.doubles();\n        case STRING:\n          return ValueWriters.strings();\n        case FIXED:\n          return ValueWriters.fixed(primitive.getFixedSize());\n        case BYTES:\n          return ValueWriters.byteBuffers();\n        default:\n          throw new IllegalArgumentException(\"Unsupported type: \" + primitive);\n      }\n    }\n  }\n}\n","sourceCodeStart":147,"sourceCodeEnd":170,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/data/avro/DataWriter.java#L147-L170","documentation":"DataWriter's primitive() method converts an Iceberg primitive type into an Avro ValueWriter. When it encounters a primitive type it has no writer case for (e.g. a type outside its supported switch of int/long/float/double/string/fixed/bytes etc.), it throws this IllegalArgumentException. It signals the write schema contains a primitive the Avro data writer cannot serialize.","triggerScenarios":"Calling GenericAvroWriter/DataWriter.write on data whose schema contains a primitive type not handled by the switch (e.g. certain logical/date-time primitives depending on version), typically reached via write(Schema, T) on a file writer built with this DataWriter.","commonSituations":"Writing tables with newer Iceberg types using an older writer path; custom or unknown primitives; type evolution adding a type the Avro writer path doesn't support; mapping a schema programmatically with a typo'd or exotic type.","solutions":["Inspect the schema and identify which primitive type lacks a case in DataWriter.primitive(), then exclude or convert that column.","Upgrade Iceberg to a version whose DataWriter supports the type.","Convert unsupported primitives (e.g. to string or bytes) in a projected schema before writing.","If the type genuinely should be supported, implement a case in the switch with an appropriate ValueWriter."],"exampleFix":"// before\nSchema schema = new Schema(Types.NestedField.required(1, \"ts\", Types.TimestampType.withZone()));\navroWriter.write(schema, record); // throws for unsupported primitive\n// after\nSchema projected = schema.select(\"id\", \"name\"); // only supported primitives\navroWriter.write(projected, record);","handlingStrategy":"validation","validationCode":"boolean allSupported(Schema schema) {\n  for (Types.NestedField f : schema.columns()) {\n    if (f.type().isPrimitiveType() &&\n        !Set.of(\"int\",\"long\",\"float\",\"double\",\"boolean\",\"date\",\"string\",\"fixed\",\"bytes\",\"time\",\"timestamp\",\"decimal\",\"uuid\").contains(f.type().toString())) {\n      return false;\n    }\n  }\n  return true;\n}\nif (!allSupported(schema)) throw new IllegalArgumentException(\"Schema has primitives unsupported by Avro writer\");","typeGuard":"if (type.isPrimitiveType() && !SUPPORTED.contains(type.typeId())) { skip or convert }","tryCatchPattern":"try { writer.write(schema, record); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported type\")) { /* project/convert schema and retry */ } else throw e; }","preventionTips":["Project schemas to known-supported primitives before writing","Keep writer and table format versions aligned","Test round-trip write/read with the full schema in CI"],"tags":["avro","serialization","unsupported-type","schema"],"backgroundTag":"unsupported-operation","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"}