{"record":{"id":"31962a7c42174cb1","repo":"apache/iceberg","slug":"unsupported-type-primitive-31962a","errorCode":null,"errorMessage":"Unsupported type: ${primitive}","messagePattern":"Unsupported type: (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java","lineNumber":188,"sourceCode":"        case LONG:\n          return ValueReaders.longs();\n        case FLOAT:\n          if (partner != null && partner.typeId() == Type.TypeID.DOUBLE) {\n            return ValueReaders.floatsAsDoubles();\n          }\n          return ValueReaders.floats();\n        case DOUBLE:\n          return ValueReaders.doubles();\n        case STRING:\n          return SparkValueReaders.strings();\n        case FIXED:\n          return ValueReaders.fixed(primitive.getFixedSize());\n        case BYTES:\n          return ValueReaders.bytes();\n        case ENUM:\n          return SparkValueReaders.enums(primitive.getEnumSymbols());\n        default:\n          throw new IllegalArgumentException(\"Unsupported type: \" + primitive);\n      }\n    }\n  }\n}\n","sourceCodeStart":170,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java#L170-L193","documentation":"The Iceberg Spark planned Avro reader throws IllegalArgumentException when an Avro field's primitive type is outside its supported set (NULL, BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, ENUM are handled). Any other Avro type reaching this primitive-level branch — typically a RECORD/ARRAY/MAP/UNION arriving where a primitive was expected — indicates a malformed or unexpected schema.","triggerScenarios":"Reading Avro data where a field's schema type does not match the reader's dispatch — e.g. a nested RECORD/UNION hitting the primitive switch due to schema mismatch between expected Iceberg schema and the file's Avro schema.","commonSituations":"Schema drift between the Iceberg table schema and the underlying Avro files; hand-written or third-party Avro files with unusual types; Avro spec features not modeled by this reader.","solutions":["Verify the Avro schema of the data files matches the Iceberg table schema (refresh metadata if the table evolved)","Rewrite the data files so nested types are properly declared rather than appearing in primitive positions","Upgrade Iceberg to a version with broader Avro type support","Use avro-tools getschema to diff the file schema against expectations and fix the producing writer"],"exampleFix":"// before: Avro field declared as union {\"type\":[\"null\",\"string\"]} where reader expects a primitive\n// after: align schema with table, or handle unions at the record level\n{\"name\":\"note\",\"type\":\"string\",\"default\":\"\"}","handlingStrategy":"validation","validationCode":"import org.apache.avro.Schema;\nboolean primitiveSafe(Schema s) {\n  switch (s.getType()) {\n    case NULL: case BOOLEAN: case INT: case LONG: case FLOAT: case DOUBLE:\n    case STRING: case FIXED: case BYTES: case ENUM: return true;\n    default: return false; // RECORD/ARRAY/MAP/UNION must not hit the primitive branch\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Iceberg table schema in sync with the Avro file schemas","Re-write files after schema evolution rather than mixing old and new schemas","Use avro-tools getschema to audit external files before registration"],"tags":["avro","spark","type-mismatch","reader"],"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"}