apache/iceberg · error · UnsupportedOperationException

Unsupported array element type:

Error message

Unsupported array element type: 

What it means

collectionToArrayData converts a collection of Iceberg values into Spark's ArrayData but only handles a fixed set of element types; any other Iceberg element type hits the default branch and throws UnsupportedOperationException with the type name. The conversion layer simply has no mapping for that element type yet.

Solutions

  1. Flatten or cast the array element to a supported type (string, struct of primitives) in the query
  2. Exclude the unsupported nested column from the projection
  3. Upgrade Iceberg/Spark integration where more element types may be supported

Example fix

// before
SELECT arr FROM t  -- arr: array<variant>
// after
SELECT transform(arr, x -> to_json(x)) AS arr FROM t
Defensive patterns

Strategy: validation

Validate before calling

if (!SUPPORTED_ELEMENT_TYPES.contains(arrayType.elementType())) {
  throw new IllegalArgumentException("Unsupported array element: " + arrayType.elementType());
}

Type guard

static boolean hasSupportedArrayElementType(Types.NestedField f) {
  return f.type().isListType() &&
    !(f.type().asListType().elementType() instanceof Types.VariantType);
}

Try / catch

try {
  ArrayData arr = row.getArray(ordinal);
} catch (UnsupportedOperationException e) {
  arr = readAsJson(ordinal);
}

Prevention

When it happens

Trigger: Reading a nested array column whose element type falls outside the supported switch cases (e.g. certain complex or newer types) through StructInternalRow's array accessor.

Common situations: Tables using newer or nested types (variant-like, custom geometry element types) inside arrays read via the Spark 4.2 row reader; version skew where writer produced types the reader cannot convert.

Related errors


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

Appendix: source

Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/StructInternalRow.java:379

        return fillArray(
            values,
            array ->
                (BiConsumer<Integer, Collection<?>>)
                    (pos, list) ->
                        array[pos] =
                            collectionToArrayData(elementType.asListType().elementType(), list));
      case MAP:
        return fillArray(
            values,
            array ->
                (BiConsumer<Integer, Map<?, ?>>)
                    (pos, map) -> array[pos] = mapToMapData(elementType.asMapType(), map));
      case VARIANT:
        return fillArray(
            values,
            array -> (BiConsumer<Integer, Object>) (pos, v) -> array[pos] = toVariantVal(v));
      default:
        throw new UnsupportedOperationException("Unsupported array element type: " + elementType);
    }
  }

  private static BinaryView toBinaryView(Type type, byte[] wkb) {
    return toBinaryView(SparkSchemaUtil.convert(type), wkb);
  }

  private static BinaryView toBinaryView(DataType type, byte[] wkb) {
    if (type instanceof GeometryType) {
      return STUtils.stGeomFromWKB(wkb, ((GeometryType) type).srid());
    } else if (type instanceof GeographyType) {
      return STUtils.stGeogFromWKB(wkb, ((GeographyType) type).srid());
    }

    throw new UnsupportedOperationException("Unsupported BinaryView type: " + type);
  }

  private static VariantVal toVariantVal(Object value) {

View on GitHub (pinned to 86d9c8fc54)