{"record":{"id":"d3000ee489121b65","repo":"apache/iceberg","slug":"unhandled-type-d3000e","errorCode":null,"errorMessage":"Unhandled type ","messagePattern":"Unhandled type ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/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/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L112-L148","documentation":"SparkOrcWriter.primitive maps Iceberg primitive types to ORC value writers. All standard primitives are covered in the switch; the default branch should be unreachable and fires only for an unrecognized primitive. This IllegalArgumentException means a type in the Iceberg schema could not be translated into an ORC writer during a Spark write.","triggerScenarios":"Writing Spark data whose Iceberg schema contains a primitive type with no writer mapping (unexpected type reaching default, e.g. unknown/future type ids not covered by the switch).","commonSituations":"Version skew where a table schema uses a type introduced in a newer spec than the writer supports; programmatic schema construction with invalid types.","solutions":["Upgrade the Iceberg Spark runtime so the writer supports the type.","Change the schema column to a supported primitive type.","Align writer and reader Iceberg versions across jobs.","Validate the table schema before writing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure table schema types are all standard Iceberg primitives before writing via Spark ORC\ntable.schema().columns().forEach(f -> {\n  if (f.type().isPrimitiveType() && f.type().typeId() == org.apache.iceberg.types.Type.TypeID.UNKNOWN) {\n    throw new IllegalStateException(\"Unsupported primitive in schema: \" + f.name());\n  }\n});","typeGuard":null,"tryCatchPattern":"try {\n  df.write().format(\"iceberg\").mode(\"append\").save(tableLocation);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unhandled type\")) {\n    // inspect schema and migrate column types\n  } else throw e;\n}","preventionTips":["Use standard Iceberg types in table schemas","Keep Iceberg versions aligned across jobs","Validate programmatic schemas before writes"],"tags":["spark","orc","writer","unsupported-type"],"backgroundTag":"unsupported-operation","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"}