apache/iceberg · error · java.lang.UnsupportedOperationException

Unsupported element type for Array or Map: %s

Error message

Unsupported element type for Array or Map: %s

What it means

elementValue converts a Variant value according to an expected Flink LogicalType; types outside the handled switch (not array/map/row/primitive cases) are rejected with this UnsupportedOperationException naming the LogicalType.

Source

Thrown at flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/VariantRowDataWrapper.java:208

      case BOOLEAN -> variant.getBoolean();
      case TINYINT -> variant.getByte();
      case SMALLINT -> variant.getShort();
      case INTEGER -> intValue(variant);
      case BIGINT -> longValue(variant);
      case FLOAT -> variant.getFloat();
      case DOUBLE -> doubleValue(variant);
      case DECIMAL -> decimalDataValue(variant, (DecimalType) elementType);
      case CHAR, VARCHAR -> StringData.fromString(variant.getString());
      case TIMESTAMP_WITHOUT_TIME_ZONE ->
          timestampValue(variant, ((TimestampType) elementType).getPrecision());
      case TIMESTAMP_WITH_LOCAL_TIME_ZONE ->
          timestampValue(variant, ((LocalZonedTimestampType) elementType).getPrecision());
      case BINARY, VARBINARY -> variant.getBytes();
      case ARRAY -> arrayDataValue(variant, ((ArrayType) elementType).getElementType());
      case MAP -> mapDataValue(variant, (MapType) elementType);
      case ROW -> new VariantRowDataWrapper((RowType) elementType).wrap(variant);
      default ->
          throw new UnsupportedOperationException(
              String.format("Unsupported element type for Array or Map: %s", elementType));
    };
  }

  private static MapData mapDataValue(Variant variant, MapType mapType) {
    if (isNull(variant)) {
      return null;
    }

    LogicalType keyType = mapType.getKeyType();
    LogicalType valueType = mapType.getValueType();

    Preconditions.checkArgument(
        keyType instanceof VarCharType,
        "Only Map with STRING key type is supported in Variant to RowData conversion");

    Map<Object, Object> mapData = Maps.newHashMap();
    List<String> keys = BinaryVariantAccessorUtils.fieldNames(variant);

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Upgrade iceberg-flink to a version supporting the element LogicalType
  2. Restructure the schema so array/map elements use supported types
  3. Flatten nested structures or store the element as a supported type (string/binary)

Example fix

// before
Types.NestedField f = schema.findField("tags"); // MAP<STRING, VARIANT>
// after
Types.NestedField f = schema.findField("tags"); // MAP<STRING, STRING> supported
Defensive patterns

Strategy: type-guard

Validate before calling

LogicalType el = arrayType.getElementType();
// ensure el is a supported primitive/row before reading array data

Type guard

boolean isSupported(LogicalType t) {
  return t instanceof IntType || t instanceof BigIntType || t instanceof VarCharType
      || t instanceof RowType || t instanceof BinaryType || t instanceof LocalZonedTimestampType;
}

Try / catch

try { return row.getArray(pos); }
catch (UnsupportedOperationException e) { /* unsupported element type: degrade to binary/string read */ }

Prevention

When it happens

Trigger: Reading an ARRAY or MAP whose element/value LogicalType is not supported by elementValue (an unmapped type) and calling mapDataValue/arrayDataValue on a non-null variant.

Common situations: Schemas containing arrays or maps of unsupported element types (e.g. nested variant or newer logical types) read with a Flink runtime lacking that support.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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