{"record":{"id":"e0f52be795863ffd","repo":"apache/iceberg","slug":"unsupported-type-e0f52b","errorCode":null,"errorMessage":"Unsupported type: ","messagePattern":"Unsupported type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/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.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java#L153-L176","documentation":"SparkAvroWriter.primitive switches over the Avro primitive type and only supports STRING, FIXED, BYTES (among the tail cases); any other primitive type falls to the default branch and throws IllegalArgumentException('Unsupported type: ' + primitive). It guards the Avro-to-Spark value-writer mapping.","triggerScenarios":"Writing Spark rows to Avro whose schema contains a primitive type the writer doesn't map (e.g. unexpected/unsupported primitive in the resolved write schema).","commonSituations":"Schema evolution or hand-built Avro schemas with primitives outside the supported set; mismatch between the table schema and the generated Avro write schema in a custom pipeline.","solutions":["Check the Avro schema and restrict fields to supported primitive types","Upgrade the Iceberg version in case support was added later","Convert unsupported primitives to supported equivalents before writing","Inspect the full exception message for the offending primitive type"],"exampleFix":"// before: writing a schema with unsupported primitive\nSchema schema = Schema.createUnion(...);\n// after: normalize to supported primitives\nSchema schema = Schema.create(Schema.Type.BYTES);","handlingStrategy":"validation","validationCode":"for (Schema.Field f : avroSchema.getFields()) {\n  Schema.Type t = f.schema().getType();\n  Preconditions.checkArgument(\n      t == Schema.Type.STRING || t == Schema.Type.FIXED || t == Schema.Type.BYTES\n          || /* other supported types */ true, \"Unsupported type: \" + t);\n}","typeGuard":null,"tryCatchPattern":"try { writer.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported type: \")) { /* normalize schema */ } else { throw e; } }","preventionTips":["Validate the Avro write schema against supported primitives before writing","Avoid hand-built Avro schemas; derive them from the Iceberg table schema","Upgrade the runtime if new primitive support is needed"],"tags":["spark","avro","writer","primitive-type","unsupported"],"backgroundTag":"type-mismatch","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"}