{"record":{"id":"a1439a4d6df1f0bf","repo":"apache/iceberg","slug":"not-a-supported-type-type","errorCode":null,"errorMessage":"Not a supported type: type","messagePattern":"Not a supported type: type","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java","lineNumber":90,"sourceCode":"        // if spark.sql.datetime.java8API.enabled is set to true, java.time.LocalDate\n        // for Spark SQL DATE type otherwise java.sql.Date is returned.\n        return DateTimeUtils.anyToDays(object);\n      case TIMESTAMP:\n        return DateTimeUtils.anyToMicros(object);\n      case BINARY:\n        return ByteBuffer.wrap((byte[]) object);\n      case INTEGER:\n        return ((Number) object).intValue();\n      case BOOLEAN:\n      case LONG:\n      case FLOAT:\n      case DOUBLE:\n      case DECIMAL:\n      case STRING:\n      case FIXED:\n        return object;\n      default:\n        throw new UnsupportedOperationException(\"Not a supported type: \" + type);\n    }\n  }\n\n  private static Record convert(Types.StructType struct, Row row) {\n    if (row == null) {\n      return null;\n    }\n\n    Record record = GenericRecord.create(struct);\n    List<Types.NestedField> fields = struct.fields();\n    for (int i = 0; i < fields.size(); i += 1) {\n      Types.NestedField field = fields.get(i);\n\n      Type fieldType = field.type();\n\n      switch (fieldType.typeId()) {\n        case STRUCT:\n          record.set(i, convert(fieldType.asStructType(), row.getStruct(i)));","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java#L72-L108","documentation":"SparkValueConverter.convert() converts Iceberg internal values to Spark-compatible values for primitive types. If a type is not handled in the switch (e.g. a nested STRUCT, LIST, or MAP is passed into this primitive-only path), it throws UnsupportedOperationException. This signals that the converter does not support the given Iceberg type for this conversion direction.","triggerScenarios":"Calling SparkValueConverter.convert(...) with a Type whose typeId() is not BOOLEAN/INTEGER/LONG/FLOAT/DOUBLE/DECIMAL/STRING/FIXED — most commonly a nested or non-primitive type such as StructType, ListType, MapType, or a timestamp/binary variant not matched by any case.","commonSituations":"Developers use SparkValueConverter directly in custom readers/writers or tests and feed it a schema containing nested or timestamp types; it typically appears when writing generic conversion code that doesn't filter to primitive types first.","solutions":["Pre-filter or branch: only call convert() for primitive types; handle StructType/ListType/MapType via convert(struct/row), convert(list), or convert(map) overloads","Add explicit handling or a clearer exception for the specific type you need converted","Check the Iceberg type of the field before conversion with type.typeId() and log/skip unsupported fields"],"exampleFix":"// before\nObject converted = SparkValueConverter.convert(field.type(), value);\n// after\nif (field.type().isPrimitiveType()) {\n  Object converted = SparkValueConverter.convert(field.type(), value);\n} else {\n  // route structs/lists/maps to their dedicated convert overloads\n}","handlingStrategy":"type-guard","validationCode":"if (!type.isPrimitiveType()) { throw new IllegalArgumentException(\"Use nested-type conversion for \" + type); }\nObject converted = SparkValueConverter.convert(type, value);","typeGuard":"boolean isConvertiblePrimitive = type != null && type.isPrimitiveType()\n    && type.typeId() != Type.TypeID.TIMESTAMP; // match the switch's handled set","tryCatchPattern":"try {\n  converted = SparkValueConverter.convert(type, value);\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"Skipping unsupported type {}\", type, e);\n  converted = null;\n}","preventionTips":["Check type.typeId() against the handled set before calling","Route STRUCT/LIST/MAP to dedicated conversion paths","Add unit tests covering every type id in your schema"],"tags":["spark","type-conversion","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}