apache/iceberg · error · UnsupportedOperationException

Unsupported element type: " + elementType

Error message

Unsupported element type: " + elementType

What it means

StructRowData.convertValue maps Iceberg StructLike values into Flink data structures according to the Iceberg element type. Its switch covers all standard Iceberg types but has a default branch that throws UnsupportedOperationException('Unsupported element type: ' + elementType) when the type id isn't handled (or when a value doesn't match the expected shape, e.g. a non-Long reaching the TIMESTAMP cast path).

Source

Thrown at flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.java:341

            array[index] = convertValue(elementType.asListType().elementType(), element);
          }

          index += 1;
        }
        return new GenericArrayData(array);
      case MAP:
        Types.MapType mapType = elementType.asMapType();
        Set<? extends Map.Entry<?, ?>> entries = ((Map<?, ?>) value).entrySet();
        Map<Object, Object> result = Maps.newHashMap();
        for (Map.Entry<?, ?> entry : entries) {
          final Object keyValue = convertValue(mapType.keyType(), entry.getKey());
          final Object valueValue = convertValue(mapType.valueType(), entry.getValue());
          result.put(keyValue, valueValue);
        }

        return new GenericMapData(result);
      default:
        throw new UnsupportedOperationException("Unsupported element type: " + elementType);
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Check which elementType is printed in the message; if it's a newer Iceberg type (e.g. variant), upgrade iceberg-flink to a version whose convertValue supports it.
  2. Remove or project out the unsupported nested column type before reading via the Flink adapter.
  3. For nested timestamp fields, ensure stored values are Long, LocalDateTime, or OffsetDateTime matching the column type.
  4. If you own the code, extend convertValue's switch to map the new type id to its Flink equivalent.

Example fix

// before
ArrayData arr = structRowData.getArray(pos); // fails for VARIANT elements

// after
Types.NestedField field = schema.findField("myList");
Preconditions.checkArgument(
    field.type().asListType().elementType().typeId() != Type.TypeID.VARIANT,
    "VARIANT list elements are not supported by StructRowData");
ArrayData arr = structRowData.getArray(pos);
Defensive patterns

Strategy: validation

Validate before calling

Type elemType = field.type().asListType().elementType();
Set<Type.TypeID> supported = Set.of(Type.TypeID.BOOLEAN, Type.TypeID.INTEGER, Type.TypeID.DATE,
    Type.TypeID.TIME, Type.TypeID.LONG, Type.TypeID.FLOAT, Type.TypeID.DOUBLE, Type.TypeID.DECIMAL,
    Type.TypeID.TIMESTAMP, Type.TypeID.TIMESTAMP_NANO, Type.TypeID.STRING, Type.TypeID.FIXED,
    Type.TypeID.BINARY, Type.TypeID.STRUCT, Type.TypeID.LIST, Type.TypeID.MAP);
Preconditions.checkArgument(supported.contains(elemType.typeId()),
    "Element type not supported by StructRowData: %s", elemType);

Type guard

boolean isConvertibleIcebergType(Type t) {
  switch (t.typeId()) {
    case VARIANT:
    case UNKNOWN:
      return false;
    default:
      return true;
  }
}

Try / catch

try {
  ArrayData arr = structRowData.getArray(pos);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().startsWith("Unsupported element type:")) {
    log.error("Nested type not supported by Flink reader: {}", e.getMessage());
    throw new UnsupportedColumnTypeException(e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Reading a list/map field via StructRowData.getArray/getMap whose element or key/value type falls through the switch (e.g. VARIANT or other newly added Iceberg types), or a nested timestamp value whose runtime type is neither LocalDateTime, OffsetDateTime, nor Long (causing the (Long) cast inside convertValue to precede this throw).

Common situations: Tables using newer Iceberg types (Variant, Unknown) read through the Flink adapter; nested timestamp columns where custom writers stored unexpected types; version mismatch between writer and reader on newly introduced type ids.

Related errors


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