{"record":{"id":"e124daabe2ad06bd","repo":"apache/iceberg","slug":"unhandled-type-e124da","errorCode":null,"errorMessage":"Unhandled type ","messagePattern":"Unhandled type ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/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.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L112-L148","documentation":"SparkOrcWriter.primitive() maps Iceberg primitive types to ORC value writers. If it encounters an Iceberg primitive type with no ORC writer mapping (anything not covered by the switch cases, e.g. types invalid for ORC storage), it throws IllegalArgumentException(\"Unhandled type ...\"). This fails writer creation for the whole file, before any rows are written.","triggerScenarios":"Writing a Spark DataFrame via the Iceberg ORC writer when the table schema contains an Iceberg primitive type not handled by the switch (e.g. Iceberg types that ORC cannot represent or that newer spec versions added without writer support in this Spark 4.0 branch).","commonSituations":"Migrating tables between formats and landing a type ORC does not support (e.g. UUID or unknown future types in this branch); using a table whose schema was created with a newer Iceberg spec than this writer supports; accidental misuse of nested/binary types mapped incorrectly to ORC.","solutions":["Check the offending Iceberg type in the table schema (spark printSchema / metadata) and convert it to an ORC-supported type","Recreate or alter the table with an ORC-compatible column type (e.g. use string/long instead of the unsupported type)","If the type is a newly added Iceberg spec type, upgrade Iceberg to a version whose Spark writer supports it","Cast unsupported columns before writing (e.g. df.withColumn(\"c\", col(\"c\").cast(\"string\")))"],"exampleFix":"// before\ndf.writeTo(\"db.table_unsupported_type\").append();\n// after\nDataset<Row> fixed = df.withColumn(\"weird\", functions.col(\"weird\").cast(\"string\"));\nfixed.writeTo(\"db.table\").append();","handlingStrategy":"validation","validationCode":"for (Types.NestedField f : table.schema().columns()) {\n  if (f.type().isPrimitiveType() && !ORC_SUPPORTED_TYPES.contains(f.type().asPrimitiveType().typeId())) {\n    throw new IllegalStateException(\"Column \" + f.name() + \" has ORC-unsupported type \" + f.type());\n  }\n}","typeGuard":"boolean isOrcWritable(Type type) {\n  switch (type.typeId()) {\n    case BOOLEAN: case INT: case LONG: case FLOAT: case DOUBLE: case DATE:\n    case TIME: case TIMESTAMP: case STRING: case UUID: case FIXED:\n    case BINARY: case DECIMAL: return true;\n    default: return false;\n  }\n}","tryCatchPattern":"try {\n  df.writeTo(\"db.tbl\").append();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unhandled type\")) {\n    // recast offending columns to ORC-supported types and retry\n  } else {\n    throw e;\n  }\n}","preventionTips":["Verify every table column type is ORC-representable before choosing write.format=orc","Cast exotic columns (e.g. unknown/future spec types) to string or binary before writing","Keep Iceberg versions aligned across producers and this Spark integration"],"tags":["orc","spark","unsupported-type","iceberg-schema"],"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-23T08:17:48.524Z"}