{"record":{"id":"cf895054fdbd01c2","repo":"apache/iceberg","slug":"encountered-an-unsupported-orc-type-during-a-write","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/v3.5/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/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L203-L239","documentation":"SparkOrcWriter.createFieldGetter selects an InternalRow accessor based on the ORC type category (STRUCT, LIST, MAP, primitives, etc.). When the ORC TypeDescription's category falls outside all handled cases, the default branch throws this IllegalArgumentException. It indicates an ORC type encountered during a Spark write that the field-getter builder cannot read values for.","triggerScenarios":"Building field getters for an ORC schema whose TypeDescription category is not handled (an ORC category outside the switch's supported set), typically from an unexpected or version-skewed ORC type mapping.","commonSituations":"Custom ORC schemas, ORC library upgrades introducing new categories, or mismatched schema wiring between Iceberg and ORC.","solutions":["Inspect the ORC schema and replace the unsupported category with a supported one.","Upgrade Iceberg to a release whose createFieldGetter covers the ORC category.","Align the ORC library version with what the Iceberg build expects.","Validate the ORC TypeDescription tree before constructing the writer."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"org.apache.orc.TypeDescription.Category cat = orcType.getCategory();\nif (cat != org.apache.orc.TypeDescription.Category.STRUCT\n    && cat != org.apache.orc.TypeDescription.Category.LIST\n    && cat != org.apache.orc.TypeDescription.Category.MAP\n    && !cat.isPrimitive()) {\n  throw new IllegalStateException(\"ORC category not supported by field getter: \" + cat);\n}","typeGuard":null,"tryCatchPattern":"try {\n  writeWithIcebergSparkOrc(rows, orcSchema);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"unsupported ORC type\")) {\n    // normalize orcSchema to supported categories and retry once\n  } else throw e;\n}","preventionTips":["Validate the ORC TypeDescription tree before constructing writers","Avoid ORC library versions introducing new categories until Iceberg supports them","Test schema wiring between Iceberg and ORC explicitly"],"tags":["spark","orc","writer","unsupported-type","schema"],"backgroundTag":"incompatible-source-type","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"}