{"record":{"id":"609a7ac7abbdd818","repo":"apache/iceberg","slug":"encountered-an-unsupported-orc-type-during-a-write-609a7a","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.1/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.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L203-L239","documentation":"SparkOrcWriter.createFieldGetter maps Iceberg/Spark field types to ORC field getter functions. The default branch fires when the column's Iceberg TypeID is not one of the supported ORC-writable types (e.g. a nested or unrecognized type id reached the switch). This is a schema-support guard: the writer cannot produce an ORC encoding for that type.","triggerScenarios":"Writing a Spark DataFrame through Iceberg's ORC writer where a column's Iceberg type resolves to a TypeID not handled by createFieldGetter's switch (e.g. an unsupported nested type variant).","commonSituations":"Using newer or exotic Iceberg types (e.g. unknown/nested types, variant-like types) with an older Spark ORC writer module; schema drift after table evolution where the writer version predates the type.","solutions":["Check the table schema for columns whose Iceberg type is unsupported by this Spark ORC writer version and drop/retype them.","Upgrade the iceberg-spark module to a version matching your Spark release so all types in the schema are supported.","Cast unsupported columns to a supported type (e.g. string/binary) before writing."],"exampleFix":"// before\n// writing table with an exotic nested type column\n// after\n// cast the column to a supported type before writing\ndf = df.withColumn(\"col\", col(\"col\").cast(\"string\"));","handlingStrategy":"validation","validationCode":"// validate all column types are supported before writing\nschema.columns().forEach(c -> Preconditions.checkArgument(\n    Set.of(BOOLEAN, INT, LONG, FLOAT, DOUBLE, DATE, TIMESTAMP, STRING, BINARY, DECIMAL, FIXED)\n        .contains(c.type().typeId()),\n    \"Unsupported ORC write type: %s\", c.type()));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep iceberg-spark version aligned with your Spark version","Review table schemas for exotic types before enabling ORC writes","Test schema evolution changes in a staging table first"],"tags":["spark","orc","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-23T08:17:48.524Z"}