{"record":{"id":"9c1f8d26426d65e7","repo":"apache/iceberg","slug":"unsupported-type-primitive-9c1f8d","errorCode":null,"errorMessage":"Unsupported type: ${primitive}","messagePattern":"Unsupported type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java","lineNumber":194,"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":176,"sourceCodeEnd":199,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java#L176-L199","documentation":"SparkPlannedAvroReader.primitive maps Avro primitive types (NULL, BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, ENUM) to value readers. Any other Avro type (e.g. RECORD, ARRAY, MAP, UNION — which should be handled by other visit methods) reaching this switch throws IllegalArgumentException.","triggerScenarios":"A nested/non-primitive Avro type routed into the primitive visit method due to a schema-planning mismatch, or a corrupted/unusual schema where a primitive branch receives an unhandled type.","commonSituations":"Schema incompatibility between the planned Iceberg schema and the Avro file schema (fields resolved to unexpected types); custom Avro types.","solutions":["Verify the table schema matches the Avro file schema; fix the Iceberg schema so planning resolves each field to the right reader.","Re-write the Avro data with a standard schema.","Upgrade Iceberg if the file uses an Avro feature newer than the bundled version."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure planned Iceberg schema fields align 1:1 with Avro primitives\navroSchema.getFields().forEach(f ->\n    Preconditions.checkArgument(f.schema().getType().isPrimitive() ||\n        f.schema().getType() == Schema.Type.ENUM ||\n        f.schema().getType() == Schema.Type.FIXED,\n        \"Unexpected Avro type for field %s: %s\", f.name(), f.schema().getType()));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Iceberg table schema in sync with the underlying Avro files","Rewrite files whose schema drifted from the table schema","Avoid hand-edited Avro schemas"],"tags":["spark","avro","schema","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}