{"record":{"id":"9907399377c06db1","repo":"apache/iceberg","slug":"encountered-an-unsupported-orc-type-during-a-write-990739","errorCode":null,"errorMessage":"Encountered an unsupported ORC type during a write from Spark.","messagePattern":"Encountered an unsupported ORC type during a write from Spark\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java","lineNumber":221,"sourceCode":"            (row, ordinal) ->\n                row.getDecimal(ordinal, fieldType.getPrecision(), fieldType.getScale());\n        break;\n      case STRING:\n      case CHAR:\n      case VARCHAR:\n        fieldGetter = SpecializedGetters::getUTF8String;\n        break;\n      case STRUCT:\n        fieldGetter = (row, ordinal) -> row.getStruct(ordinal, fieldType.getChildren().size());\n        break;\n      case LIST:\n        fieldGetter = SpecializedGetters::getArray;\n        break;\n      case MAP:\n        fieldGetter = SpecializedGetters::getMap;\n        break;\n      default:\n        throw new IllegalArgumentException(\n            \"Encountered an unsupported ORC type during a write from Spark.\");\n    }\n\n    return (row, ordinal) -> {\n      if (row.isNullAt(ordinal)) {\n        return null;\n      }\n      return fieldGetter.getFieldOrNull(row, ordinal);\n    };\n  }\n\n  interface FieldGetter<T> extends Serializable {\n\n    /**\n     * Returns a value from a complex Spark data holder such ArrayData, InternalRow, etc... Calls\n     * the appropriate getter for the expected data type.\n     *\n     * @param row Spark's data representation","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L203-L239","documentation":"While creating the field getter for a column, SparkOrcWriter switches on the ORC type category (struct, list, map, primitive). An ORC type outside the supported categories triggers this IllegalArgumentException, indicating the ORC schema contains a type the Spark write path cannot read values from.","triggerScenarios":"Writing to ORC where a column's ORC TypeDescription category is not STRUCT/LIST/MAP/PRIMITIVE (e.g. UNION type in the ORC schema).","commonSituations":"Reading/writing ORC files produced by non-Iceberg tools that use ORC union types; hand-edited ORC schemas.","solutions":["Remove or rewrite ORC union-typed columns; Iceberg does not support ORC unions.","Regenerate files with an Iceberg-supported schema.","Check the file schema with orc-tools (meta) to identify the unsupported category."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for (TypeDescription child : fileSchema.getChildren()) {\n  switch (child.getCategory()) {\n    case STRUCT: case LIST: case MAP: case UNION: -> { if (child.getCategory() == TypeDescription.Category.UNION) throw new IllegalStateException(\"ORC union unsupported: \" + child); }\n    default -> {}\n  }\n}","typeGuard":"boolean orcTypeSupported(TypeDescription t) {\n  return t.getCategory() != TypeDescription.Category.UNION;\n}","tryCatchPattern":"try {\n  sparkOrcWriter.write(rows);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"unsupported ORC type\")) {\n    // rewrite files without union columns\n  }\n}","preventionTips":["Avoid ORC union types in files destined for Iceberg.","Inspect file schemas with orc-tools before ingestion."],"tags":["orc","spark","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-23T08:17:48.524Z"}