{"record":{"id":"c8f68776eb188de5","repo":"apache/iceberg","slug":"unsupported-type-primitive-c8f687","errorCode":null,"errorMessage":"Unsupported type: ${primitive}","messagePattern":"Unsupported type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java","lineNumber":171,"sourceCode":"            return ValueWriters.tinyints();\n          } else if (type instanceof ShortType) {\n            return ValueWriters.shorts();\n          }\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 SparkValueWriters.strings();\n        case FIXED:\n          return ValueWriters.fixed(primitive.getFixedSize());\n        case BYTES:\n          return ValueWriters.bytes();\n        default:\n          throw new IllegalArgumentException(\"Unsupported type: \" + primitive);\n      }\n    }\n  }\n}\n","sourceCodeStart":153,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java#L153-L176","documentation":"SparkAvroWriter.primitive's final switch maps Avro primitive types (INT, LONG, FLOAT, DOUBLE, BOOLEAN, STRING, FIXED, BYTES, etc.) to value writers and throws IllegalArgumentException for any remaining type. It is the terminal guard for Avro types the Spark writer cannot serialize.","triggerScenarios":"Writing a Spark dataset to Iceberg Avro format when the schema contains an Avro primitive type outside the handled set (e.g. NULL type reaching this switch, or exotic primitives).","commonSituations":"Malformed or auto-generated Avro schemas with NULL-typed fields; schemas from external tools with unusual primitives.","solutions":["Remove/replace the unsupported field in the Avro schema before writing.","Upgrade the Iceberg runtime if the type should be supported by a newer writer.","Cast the offending column to a supported type upstream of the write."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate Avro schema contains only supported primitives before write\nfor (Schema.Field f : schema.getFields()) { /* check f.schema().getType() in supported set */ }","typeGuard":"boolean supported(Schema s) { switch (s.getType()) { case INT: case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case STRING: case FIXED: case BYTES: return true; default: return false; } }","tryCatchPattern":"try { write(dataset); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported type\")) { /* correct schema */ } else throw e; }","preventionTips":["Sanitize externally generated Avro schemas before Iceberg writes","Drop NULL-typed or exotic primitive fields","Cast unsupported columns to supported primitives upstream"],"tags":["spark","avro","writer","unsupported-type"],"backgroundTag":"unsupported-dtype","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"}