{"record":{"id":"abff61d68bd7e3c9","repo":"apache/iceberg","slug":"unsupported-type-abff61","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/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.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java#L176-L199","documentation":"SparkPlannedAvroReader.primitive() switches on the Avro primitive schema type (NULL, BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, ENUM). Any Avro primitive not covered — such as RECORD or ARRAY appearing where a primitive is expected, or future Avro types — reaches the default branch and throws IllegalArgumentException with the schema. Reader construction fails for the file.","triggerScenarios":"Planning an Avro read where a field's Avro schema type is not one of the handled primitive cases, e.g. a nested record/array reaching primitive() due to a schema-mapping mismatch, or an unrecognized Avro type name.","commonSituations":"Malformed or hand-edited Avro schemas; producer/consumer schema drift where a field changed from primitive to nested without updating the Iceberg schema; bugs in schema projection code passing the wrong schema node.","solutions":["Print the Avro file schema and verify the field types; ensure nested types are handled by the reader factory, not primitive()","Rewrite the data files with a schema that matches the Iceberg table schema","Refresh/repair the table metadata so Iceberg's projected schema matches the files' Avro schema","Upgrade Iceberg if a newly supported Avro type is involved"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for (Field f : avroSchema.getFields()) {\n  Schema.Type t = f.schema().getType();\n  if (!(t == Schema.Type.NULL || t == Schema.Type.BOOLEAN || t == Schema.Type.INT\n      || t == Schema.Type.LONG || t == Schema.Type.FLOAT || t == Schema.Type.DOUBLE\n      || t == Schema.Type.STRING || t == Schema.Type.FIXED || t == Schema.Type.BYTES\n      || t == Schema.Type.ENUM)) {\n    throw new IllegalStateException(\"Unexpected Avro type at primitive level: \" + t);\n  }\n}","typeGuard":"boolean isSupportedAvroPrimitive(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:\n      return true;\n    default:\n      return false;\n  }\n}","tryCatchPattern":"try {\n  spark.read().format(\"iceberg\").load(\"db.tbl\");\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported type: \")) {\n    // verify the Avro schema matches the Iceberg table schema and rewrite the file if needed\n  } else {\n    throw e;\n  }\n}","preventionTips":["Keep the Avro files' schema in sync with the Iceberg table schema (nested types must nest, not flatten)","Validate Avro schemas with avro-tools before ingesting externally written files","Avoid hand-edited Avro schemas; regenerate them from the canonical Iceberg schema"],"tags":["avro","spark","schema","reader"],"backgroundTag":"unsupported-enum-value","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"}