apache/iceberg · error · IllegalArgumentException

Encountered an unsupported ORC type during a write from Spar

Error message

Encountered an unsupported ORC type during a write from Spark.

What it means

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.

Source

Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java:221

            (row, ordinal) ->
                row.getDecimal(ordinal, fieldType.getPrecision(), fieldType.getScale());
        break;
      case STRING:
      case CHAR:
      case VARCHAR:
        fieldGetter = SpecializedGetters::getUTF8String;
        break;
      case STRUCT:
        fieldGetter = (row, ordinal) -> row.getStruct(ordinal, fieldType.getChildren().size());
        break;
      case LIST:
        fieldGetter = SpecializedGetters::getArray;
        break;
      case MAP:
        fieldGetter = SpecializedGetters::getMap;
        break;
      default:
        throw new IllegalArgumentException(
            "Encountered an unsupported ORC type during a write from Spark.");
    }

    return (row, ordinal) -> {
      if (row.isNullAt(ordinal)) {
        return null;
      }
      return fieldGetter.getFieldOrNull(row, ordinal);
    };
  }

  interface FieldGetter<T> extends Serializable {

    /**
     * Returns a value from a complex Spark data holder such ArrayData, InternalRow, etc... Calls
     * the appropriate getter for the expected data type.
     *
     * @param row Spark's data representation

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the ORC schema and replace the unsupported category with a supported one.
  2. Upgrade Iceberg to a release whose createFieldGetter covers the ORC category.
  3. Align the ORC library version with what the Iceberg build expects.
  4. Validate the ORC TypeDescription tree before constructing the writer.
Defensive patterns

Strategy: try-catch

Validate before calling

org.apache.orc.TypeDescription.Category cat = orcType.getCategory();
if (cat != org.apache.orc.TypeDescription.Category.STRUCT
    && cat != org.apache.orc.TypeDescription.Category.LIST
    && cat != org.apache.orc.TypeDescription.Category.MAP
    && !cat.isPrimitive()) {
  throw new IllegalStateException("ORC category not supported by field getter: " + cat);
}

Try / catch

try {
  writeWithIcebergSparkOrc(rows, orcSchema);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("unsupported ORC type")) {
    // normalize orcSchema to supported categories and retry once
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Custom ORC schemas, ORC library upgrades introducing new categories, or mismatched schema wiring between Iceberg and ORC.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/cf895054fdbd01c2. Report an issue: GitHub.