{"record":{"id":"574eb451220eb620","repo":"apache/iceberg","slug":"unhandled-type-primitive-574eb4","errorCode":null,"errorMessage":"Unhandled type {primitive}","messagePattern":"Unhandled type (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java","lineNumber":130,"sourceCode":"          return GenericOrcWriters.floats(ORCSchemaUtil.fieldId(primitive));\n        case DOUBLE:\n          return GenericOrcWriters.doubles(ORCSchemaUtil.fieldId(primitive));\n        case BINARY:\n          if (Type.TypeID.UUID == iPrimitive.typeId()) {\n            return SparkOrcValueWriters.uuids();\n          }\n          return GenericOrcWriters.byteArrays();\n        case STRING:\n        case CHAR:\n        case VARCHAR:\n          return SparkOrcValueWriters.strings();\n        case DECIMAL:\n          return SparkOrcValueWriters.decimal(primitive.getPrecision(), primitive.getScale());\n        case TIMESTAMP_INSTANT:\n        case TIMESTAMP:\n          return SparkOrcValueWriters.timestampTz();\n        default:\n          throw new IllegalArgumentException(\"Unhandled type \" + primitive);\n      }\n    }\n  }\n\n  private static class InternalRowWriter extends GenericOrcWriters.StructWriter<InternalRow> {\n    private final List<FieldGetter<?>> fieldGetters;\n\n    InternalRowWriter(\n        List<OrcValueWriter<?>> writers, Types.StructType iStruct, List<TypeDescription> orcTypes) {\n      super(iStruct, writers);\n      this.fieldGetters = Lists.newArrayListWithExpectedSize(orcTypes.size());\n\n      Map<Integer, TypeDescription> idToType =\n          orcTypes.stream().collect(Collectors.toMap(ORCSchemaUtil::fieldId, s -> s));\n\n      for (Types.NestedField iField : iStruct.fields()) {\n        fieldGetters.add(createFieldGetter(idToType.get(iField.fieldId())));\n      }","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L112-L148","documentation":"SparkOrcWriter.primitive() maps Iceberg primitive types to ORC value writers; the default branch throws IllegalArgumentException for any primitive outside the handled set (BOOLEAN..DECIMAL, TIMESTAMP*, DATE, BINARY, etc.). This guards against writing Iceberg types that have no ORC representation in this writer path.","triggerScenarios":"Writing a table whose schema contains a primitive type the ORC writer does not map — e.g. UUID or variant via a Spark ORC write path that lacks those cases.","commonSituations":"Writing tables with Iceberg v3 types (uuid, variant) through the Spark ORC data writer; version gaps where the type was added to the spec but not the ORC writer; schema evolution adding new column types.","solutions":["Upgrade Iceberg to a version whose SparkOrcWriter supports the type","Exclude or cast the unsupported column before writing (e.g. store uuid as fixed(len) bytes or string)","Use Parquet instead of ORC for tables using uuid/variant columns","Check SparkOrcWriter.primitive() for the supported type list"],"exampleFix":"// before\ntable.updateSchema().addColumn(\"id\", Types.UUIDType.get()).commit()\n// after (ORC path)\ntable.updateSchema().addColumn(\"id\", Types.StringType.get()).commit()","handlingStrategy":"validation","validationCode":"table.schema().columns().forEach(c -> {\n  Type.TypeID id = c.type().typeId();\n  Set<Type.TypeID> supported = Set.of(Type.TypeID.BOOLEAN, Type.TypeID.INTEGER, Type.TypeID.LONG,\n      Type.TypeID.FLOAT, Type.TypeID.DOUBLE, Type.TypeID.DATE, Type.TypeID.TIME, Type.TypeID.TIMESTAMP,\n      Type.TypeID.STRING, Type.TypeID.UUID, Type.TypeID.DECIMAL, Type.TypeID.BINARY);\n  if (!supported.contains(id)) {\n    throw new IllegalStateException(\"Type not writable to ORC via SparkOrcWriter: \" + c.type());\n  }\n});","typeGuard":"boolean orcWritable(Type t) {\n  return Set.of(Type.TypeID.BOOLEAN, Type.TypeID.INTEGER, Type.TypeID.LONG, Type.TypeID.FLOAT,\n      Type.TypeID.DOUBLE, Type.TypeID.DATE, Type.TypeID.TIME, Type.TypeID.TIMESTAMP,\n      Type.TypeID.STRING, Type.TypeID.DECIMAL, Type.TypeID.BINARY).contains(t.typeId());\n}","tryCatchPattern":"try {\n  writer.write(row);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unhandled type\")) { /* cast the column or switch file format */ }\n  else throw e;\n}","preventionTips":["Check type support per file format before schema changes","Use Parquet for uuid/variant columns","Keep Iceberg updated for new spec type support"],"tags":["spark","orc","writer","unsupported-type"],"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-14T16:17:12.679Z"}