{"record":{"id":"eae5da10b39f653f","repo":"apache/iceberg","slug":"encountered-an-unsupported-orc-type-during-a-write-eae5da","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.0/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.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java#L203-L239","documentation":"SparkOrcWriter.createFieldGetter() maps an ORC TypeDescription category to a getter that extracts the field from Spark's InternalRow. If the ORC type is a category the writer does not support (the default branch of the switch over TypeDescription.Category), it throws IllegalArgumentException indicating an unsupported ORC type during a write from Spark. This occurs during writer construction for a column.","triggerScenarios":"Building a field getter for an ORC column whose TypeDescription.Category is not one of the handled cases (e.g. unusual ORC categories not produced by the normal Iceberg-to-ORC mapping).","commonSituations":"Writing to ORC files with externally supplied or corrupted schemas; bugs in schema-mapping code that produce ORC types outside the supported set; writing Iceberg data with a hand-crafted ORC writer configuration.","solutions":["Print the column's TypeDescription and confirm its category is supported (struct, list, map, and the primitive cases handled by the switch)","Ensure the ORC schema is derived from the Iceberg table schema, not hand-built","Upgrade Iceberg if the ORC type comes from a newer spec/version with additional categories","Fix any custom schema-evolution or file-merging logic that introduces unsupported ORC categories"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"switch (orcType.getCategory()) {\n  case STRUCT: case LIST: case MAP: case BOOLEAN: case BYTE: case SHORT: case INT:\n  case LONG: case FLOAT: case DOUBLE: case STRING: case VARCHAR: case CHAR:\n  case DECIMAL: case TIMESTAMP: case TIMESTAMP_INSTANT: case DATE: case BINARY:\n    break;\n  default:\n    throw new IllegalStateException(\"Unsupported ORC category: \" + orcType.getCategory());\n}","typeGuard":null,"tryCatchPattern":"try {\n  spark.sql(\"INSERT INTO catalog.db.tbl SELECT * FROM src\");\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"unsupported ORC type during a write from Spark\")) {\n    // inspect the ORC schema of the offending column and fix it before retrying\n  } else {\n    throw e;\n  }\n}","preventionTips":["Never inject externally built ORC schemas into Iceberg write paths","Validate ORC file schemas with orc-tools when ingesting files from other producers","Keep the ORC schema strictly derived from the Iceberg table schema"],"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"}